Learn from:http://bjtdeyx.iteye.com/blog/1447300The most common statements for SQL date queries -- query data on the first anniversary of the date of the day select * from shoporder where datediff (Week,ordtime,getdate () - 1 ) = 0 --
Datediff usage in SQL Server
Datediff function [Date and Time]
FunctionReturns the interval between two dates.
SyntaxDatediff (date-part, date-expression-1, date-expression-2)
Date-part:Year | quarter | month | week | Day | hour | minute |Second |
DATEDIFF function [date and time]The function returns the interval between two dates.Grammar DATEDIFF (Date-part, date-expression-1, date-expression-2)Date-part:year | Quarter | Month | Week | Day | Hour | Minute | Second | MillisecondThe parameter
Address: http://sunboyyyl.blog.163.com/blog/static/224738120112874910613/
Datediff function [Date and Time]
Function: returns the interval between two dates.
SyntaxDatediff (date-part, date-expression-1, date-expression-2)
Date-part: Year |
Returns a time interval between two dates. GrammarDateDiff (interval, date1, date2 [, firstdayofweek][, FirstWeekOfYear]])The syntax for the DATEDIFF function has the following parameters:Parameter Description Interval must be selected. A string
Grammar:DATEDIFF (datepart,startdate,enddate)The datepart parameter can be the following value:Date-part:year | Quarter | Month | Week | Day | Hour | Minute | Second | MillisecondThe parameter date-part specifies the date portion of the interval to
PHP implementation of DateDiff and DateAdd time function code sharing, Datediffdateadd
Extended time functions in PHP DateDiff and DateAdd
function DateDiff ($part, $begin, $end) {$diff = Strtotime ($end)-Strtotime ($begin), switch ($part) {case "Y"
Select Day (createtime) from Life_unite_product--the days value of the Take time fieldSelect Month (createtime) from Life_unite_product--take the month value of the Time fieldSelect year (createtime) from Life_unite_product--the yearly value of the
DateDiff is commonly used to calculate date difference functions, using the following syntax:DATEDIFF (DatePart, StartDate, EndDate)Where parameter datepart has the following options (only common parameters are listed):
DatePart
The DATEDIFF () function returns the number of days between two dates.SyntaxDATEDIFF (datepart, startdate, enddate)The startdate AND enddate parameters are valid date expressions.You need to know how many days the difference between a specified date
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.