Query the last Sunday of the week of the given date (Sunday is the first day) SQL statement declare @ date & nbsp; datetimeset @ dategetdate () -- idea: the day of the week where the current log is located minus one week -- datepart (weekday, date)
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
This week, 1st, returns the result format: 2014-5-5 0:00:00public static DateTime Getmondaydate (){DateTime Dt=datetime.now;int today= (int) dt. DayOfWeek;if (dt. Dayofweek.tostring ()! = "Sunday")//You can also use the today!=0{Return dt. AddDays (1
Mondayecho Date (' y-m-d ', (Time ()-((Date (' W ') ==0?7:date (' W ') ')-1) *24*3600)); W is the number form of the day of the week, where 0 is SundayThis Sundayecho Date (' y-m-d ', (Time () + (7-(' W ') ==0?7:date (' W ')) *24*3600)); Also use W
Queries the previous Sunday (Sunday is first day) SQL statement for the week on which the given date is located
DECLARE @date datetime
Set @date = GETDATE ()
--Train of thought: The current Diary of the Week in Sunday minus 1 weeks
The return
This MondayEcho date ('Y-m-d', (Time ()-(date ('W') = 0? 7: Date ('W')-1) * 24*3600); // W indicates the number of weeks. 0 indicates Sunday.This SundayEcho date ('Y-m-d', (Time () + (7-(date ('W') = 0? 7: Date ('W') * 24*3600); // W is also used,
These two tips, do not write do not know, a write scare!
Are seemingly simple, actually do up on the Meng, have to think carefully, can write right!
All have the date operation of the program should be careful Oh!
Let's say the second one:
2.
The Ext.date is a single example that encapsulates a series of date manipulation functions, extending the functionality of JavaScript date, and lists some of the common features listed below. Basic functions:
The
Ext.Date.add (date,
Php date instance: get last week, this week, last month, this month, this quarter, last quarter
For example, php obtained last week, this week, last month, this month, this quarter, and the last quarter.
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.