Detediff function detailed

zhaozj2021-02-16  121

Description Returns the time interval between the two dates.

Syntax Datediff (Interval, Date1, Date2 [, FirstDayofwek]]) The syntax of the Datediff function has the following parameters: Interval must. String expressions indicate time intervals for calculating DATE1 and DATE2. For values, see the "Settings" section. Date1, Date2 must. Date expression. Two dates used to calculate. Firstdayofweek is optional. Specifies the constant of the first day in the week. If not specified, the default is Sunday. For values, see the "Settings" section. Firstweekofyear is optional. Specifies the constant of the first week in the year. If you don't specify, the Week of January 1 is the week. For values, see the "Settings" section.

Setting the interval parameter can have the following values: YYYY Year Q quarter M Month Y year's day number D day W One week's day number ww week h hours m minutes s second firstdayofweek parameter can have the following values: Vbusesystem 0 Using Regional Language Support (NLS) API Set. VBSunday 1 Sunday (default) VBMONDAY 2 Monday VBTESDAY 3 Tuesday VBwednesday 4 Wednesses VBTHURSDAY 5 Thursday VBFriday 6 Friday VBSATURDAY 7 Saturday FIRSTWEEKOFYEAR parameters can have the following values: VBuseSystem 0 Using regional Language Support (NLS) API settings. VBFirstJAN1 1 starts from the week of January 1 (default). VBFirstfourDays 2 starts with at least four days in the New Year. VBFirstfulWeek 3 starts with the first complete week in the new year.

Note The dateDiff function is used to determine the number of specified time intervals existing between two dates. For example, you can use Datediff to calculate the number of days of the difference between the two dates, or the number of days between the last day of the year. To calculate the number of days of Date1 and Date2, you can use the "One Year" ("Y") or "Day" ("D"). When Interval is "a week" ("W"), DateDiff returns the number of days between two dates. If DATE1 is Monday, DateDiff calculates the number of days before DATE2. This result contains DATE2 without containing DATE1. If Interval is "Week" ("WW"), the dateDiff function returns the number of days between the two dates in the calendar. The function calculates the number of days between Date1 and Date2. If DATE2 is Sunday, DateDiff will calculate DATE2, but even if Date1 is Sunday, Date1 will not be calculated. If DATE1 is later than DATE2, the dateDiff function returns a negative number. The FirstdayOfweek parameter affects the calculation of "W" and "WW" interval symbols. If DATE1 or DATE2 is the date text, the specified year will become a fixed part of the date. However, if Date1 or Date2 is included in quotation marks ("") and omitted year, the current year is inserted each time the Date1 or Date2 expression is calculated every time the code is calculated. This will be written for program code applicable to different years. When INTERVAL is "YYYY", compare January 1, December 31, while actually only differ one day, DateDiff returns 1 indicates a year of different years.

转载请注明原文地址:https://www.9cbs.com/read-8342.html

New Post(0)