PHP obtains the year, month, and day of the current week based on the year, month, and day of the current day.
// Obtain the end date of the latest week corresponding to the year, month, and day.
Function
/** * Gets the first and last day of the week of the specified date, with an underscore connection * @param datastr * @return * @throws parseexception*/ Public Staticstring Getfirstandlastofmonth (String datastr,string dateformat,string Resultdateformat) throws ParseException { //get the first day of the current month:Calendar C =calendar.getinstance (); C.se
Mysql obtains the first day of the quarter, the first day of the month, and the first day of the week.
On the first day of this quarter, you can convert the string to the date. There are many methods, including aliases (synonyms) of the same function. For example, CURDATE ()
first day of the quarter with a MySQL statement DateConcat (Year (Curdate ()), '-',if (Quarter (Curdate ()) =1,1,if (Quarter (Curdate ()) =2,4,if (Quarter (Curdate ()) =3,7,10)) Get the first day of the quarter with a MySQL statement:Optimization:DateConcat (Year (Curdate ()), '-', ELT (quarter (Curdate ()), 1,4,7,10), '-', 1)) The first day of the weekDate_add
Label:SELECT current_date-(DAYOFWEEK (current_date)-2 + (Row_number () over (ORDER in 1))) Day as Resultfrom SYSIBM. Syscolumnsfetch first 7 rows only; output: 2013-03-24 2013-03-23 2013-03-22 2013-03-21 2013-03-20 2013-03-19 2013-03-18 You can see the sentiment The situation, you do a bit of sorting. Cross-examine the minor changes can find out what you said the result is only you this method is to check out all the dates before last
Obtain the date of a week based on a week of a year. For example, if the start date is set to "Thursday" to "Friday" of the next week, you can refer to the following requirements when getting the JS date: Obtain the date of the week based on a week of a year. For example, th
Function
/*
Every function has only one sentence!
In fact, from another blog I dug out:
T-SQL generates two new true Gregorian calendars
Http://blog.csdn.net/playyuer/archive/2004/04/07/2860.aspx
T-SQL generates a simple Gregorian calendar T-SQL contains the date of the month and the Year of the week
Http://blog.csdn.net/playyuer/archive/2004/04/05/2859.aspx
Due to the use of (@ @datefirst + datepart (weekday, @date))% 7 judgment
JS to get the current day of the week and the week beforevarSetweek =function(num) {Switch(num) { Case0: returnDay Case1: returnA Case2: returnTwo Case3: returnThree Case4: returnFour Case5: returnFive Case6: returnSix }}vararr = [] for(vari = 0; I ) {a++if(A > 6) A = 0varb =Setweek (a) Arr.push (b)}console.log
, Calendar.MONDAY); SimpleDateFormat format = new SimpleDateFormat(pattern); if (pattern = = NULL | | pattern.equals ("")) {pattern = "yyyy-mm-dd";} Return Format.format (Currentdate.gettime ());} /** * @description: Gets the end time of the week * @param pattern time format * @return end of the week * @author: * @createTime: December 13, 2016 PM 4:28:58 */publ IC static string Getweekend (string pattern) {
[Go to] obtain the first day of the current week, month, and quarter in MySQL on the last day. The last day of the current week, month, and quarter in MySQL is taken from: hideto. javaeye. comblog255816 the first day of the curren
Thought: Based on the DayOfWeek attribute of the DateTime class, we get the English name of the week, and then get the Monday by adding and subtraction of date days.1. Call:String today = "2015-7-13";//system.datetime.now.tostring ();Lblday.text = Getmondayoftheweek (today);2. Method:private string Getmondayoftheweek (string today){String smonday = "";DateTime Datenow;try{Datenow= Convert.todatetime (today);}Catch{Smonday= "Method Getmondayofweeks pas
First, use your formula to compile a simple program:
Main ()
{Int year;/* year */
Intw;/* day of the week */
Scanf ("% d", year );
W = (year-1) + (year-1)/4-(year-1)/100 + (year-1)/400 + 1) % 7;
Printf ("% d \ n", W );
Getch ();
}
Enter 1 during running. Expected result 1 is displayed. That is, if this formula is correct, Monday is the first day of Year 1. This
Calculates the 2nd day of the week on which the given date is located (Sunday is the first day)
DECLARE @date datetime
Set @date = GETDATE ()
--Train of thought: current date + Monday (2nd day of the week) and the difference between the current date and the number of da
// Determine the date based on the number of weeksPrivate datetime getweekofdate (INT year, int I){// Int month = 1;Datetime yeard = new datetime (year, 1, 1 );Int week = convert. toint32 (yeard. dayofweek );If (week = 0){Week = 7;}
Int outday = I * 7-(week-1); // throw the excess days to the
= 31;
Break
}
The circumstances of the Moon plus 30.
Case 4:
Case 6:
Case 9:
Case 11:{
days = 30;
Break
}
February situation, according to the type of year to add
Case 2:{
if (Isleapyear (year)) {
days = 29; Leap year plus 29
}
else {
days = 28;
}
Break
}
}
}
Day = day * 1;
Days = day; Number of days of the month plus days
var date0 =
/// ///Some extensions of datetime/// Public classDateTime2 {/// ///get the first day of the week (first day of Sunday)/// /// /// Publicdatetime Getweekfirstdaysun (datetime datetime) {//Sunday for the first day intWeeknow =Convert.ToInt32 (DateTime. DayOfWee
Compile a simple calendar. Enter the date to be searched in the text box. The program can calculate the week number of the day in the year and determine the day number of the week. For more information, seeFor interaction, we should select Js for implementation, which is also the first test of Pair programming. I will
CallSettimerange (2);function Settimerange (v) {var FMT = ' Yyyy-mm-dd hh:mm ';var now = new Date ();var end = new Date ();if (v = = 0) {} else if (v = = 1) {} else if (v = = 2) {YesterdayNow.setdate (now.getdate ()-1);End.setdate (end.getdate ()-1);} else if (v = = 3) {Weekvar Nowdayofweek = Now.getday (); The day of the week todayif (nowdayofweek = = 0) {Nowdayofweek = 6;//sunday} else {Nowdayofweek = now
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.