Usage of the datediff Function

Source: Internet
Author: User
Tags date1
The datediff function returns the interval between two dates. Format:
Datediff (interval, date1, date2 [, firstdayofweek [, firstweekofyear])

Parameters
Interval
Required. String expression indicates the time interval between date1 and date2. Date1, date2
Required. Date expression. Two dates used for calculation.
Firstdayofweek
Optional. Specify the constant of the first day of the week. If not specified, the default value is Sunday. For values, see the "Settings" section.
Firstweekofyear
Optional. Specifies the constant of the first week of a year. If this parameter is not specified, the default value is the week of April 1, January 1. For values, see the "Settings" section.

Yyyy
Q quarter
N months
Y number of days in a year
D
Number of days per week
WW week
H hour
M minutes
S seconds

Example: Find all records added to the table today
Select
From
Inout_public_oldsterrecord
Where
Datediff ("D", createdatetime_dat, getdate () = 0

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.