Date function
Description: Returns the current system date.
Syntax: Date
DATEADD function
Description: Returns the date when the specified time interval has been added.
Syntax: DateAdd (interval, number, date)
Interval: Must choose. A string expression that represents the time interval to add. For numeric values, see the "Settings" section.
Number: Must be selected. Numeric expression that represents the number of time intervals to add. Numeric expressions can be positive (get future dates) or negative numbers (get past dates).
Date: Must be selected. Variant or text to be added to the interval representation date.
The interval parameter can have the following values:
YYYY (year), Q (Quarter), M (month), Y (Day of year), D (Day), W (Day of Week), WW (week), H (hour), N (minutes), S (sec)
Description: Use the DATEADD function to add or subtract a specified time interval from a date. For example, you can use DATEADD to calculate the date 30 days from today or 45 minutes from now. To add a time interval of "Day" to date, you can use the number of days per year (y), day (d), or number of days of the Week (W).
The DATEADD function does not return an invalid date. The following example adds one months to January 31, 95:
Newdate = DateAdd ("M", 1, "31-jan-95")
In this case, DATEADD returns February 28, 95, not February 31, 95. If date is January 31, 96, it returns February 29, 96, because 1996 is a leap year.
An error occurs if the calculated date is before 100 A.D.
If number is not a Long value, it is rounded to the nearest integer before being evaluated.
DateDiff function
Description: Returns the time interval between two dates.
Syntax: DateDiff (interval, date1, date2 [, firstdayofweek[, firstweekofyear>)
Interval: Must choose. A string expression that is used to calculate the time interval between Date1 and Date2. For numeric values, see the "Settings" section.
Date1, Date2: Must choose. An expression of a date. Two dates used for the calculation.
FirstDayOfWeek: Optional. Specifies the constant for the first day of the week. If not specified, the default is Sunday. For numeric values, see the "Settings" section.
FirstWeekOfYear: Optional. Specifies a constant for the first week of the year. If not specified, the default is the week of January 1. For numeric values, see the "Settings" section.
The interval parameter can have the following values:
YYYY (year), Q (Quarter), M (month), Y (Day of year), D (Day), W (Day of Week), WW (week), H (hour), N (minutes), S (sec)
The FirstDayOfWeek parameter can have the following values:
(The following are: Constant numerical description)
Vbusesystem 0 uses the regional language Support (NLS) API settings.
Vbsunday 1 week day (default)
Vbmonday 2 weeks A
Vbtuesday 3 week Two
Vbwednesday 4 week Three
Vbthursday 5 week Four
Vbfriday 6 Friday
Vbsaturday 7 Saturday
The FirstWeekOfYear parameter can have the following values:
(The following are: Constant numerical description)
Vbusesystem 0 uses the regional language Support (NLS) API settings.
VbFirstJan1 1 begins on the week of January 1 (default).
vbFirstFourDays 2 begins with the first week of at least four days in the new year.
Vbfirstfullweek 3 begins with the first full week of the new Year.
Description: The DateDiff function is used to determine the number of specified time intervals that exist between two dates. For example, you can use DateDiff to calculate the number of days between two date differences, or the day to the last day of the year.
To calculate the number of days between Date1 and Date2, you can use "Days of the Year" ("Y") or "Day" ("D"). When interval is the number of days of the Week ("W"), DateDiff returns the number of weeks between two dates. If the date1 is Monday, then DateDiff calculates the number of Monday before Date2. This result contains date2 and does not contain date1. If interval is "Week" ("WW"), the DateDiff function returns the number of weeks between two dates in the Calendar table. function calculates the number of Sunday between Date1 and Date2. If the date2 is Sunday, DateDiff will calculate the date2, but even if Date1 is Sunday, it will not calculate date1.
If Date1 is later than Date2, the DateDiff function returns a negative number.
The FirstDayOfWeek parameter affects computations that use the "w" and "ww" interval symbols.
If Date1 or date2 is a date literal, the specified year becomes a fixed part of the date. However, if the Date1 or date2 is included in quotation marks ("") and the year is omitted, the current year is inserted each time the Date1 or date2 expression is evaluated in the code. This allows you to write program code that works for different years.
When interval is "year" ("yyyy"), comparing the January 1 of December 31 and the following year, although the actual difference is only one day, DateDiff returns 1 to indicate a difference of a year.
DatePart function
Description: Returns the specified portion of a given date.
Grammar: DatePart (interval, date[, firstdayofweek[, firstweekofyear>)
DatePart: The syntax of a function has the following parameters:
Interval: Must choose. A string expression that represents the time interval to return. For numeric values, see the "Settings" section.
Date: Must be selected. The date expression to evaluate.
Firstdayof Week: Optional. Specifies the constant for the first day of the week. If not specified, the default is Sunday. For numeric values, see the "Settings" section.
FirstWeekOfYear: Optional. Specifies a constant for the first week of the year. If not specified, the default is the week of January 1. For numeric values, see the "Settings" section.
The interval parameter can have the following values:
YYYY (year), Q (Quarter), M (month), Y (Day of year), D (Day), W (Day of Week), WW (week), H (hour), N (minutes), S (sec)
The FirstDayOfWeek parameter can have the following values:
(The following are: Constant numerical description)
Vbusesystem 0 uses the regional language Support (NLS) API settings.
Vbsunday 1 week day (default)
Vbmonday 2 weeks A
Vbtuesday 3 week Two
Vbwednesday 4 week Three
Vbthursday 5 week Four
Vbfriday 6 Friday
Vbsaturday 7 Saturday
The FirstWeekOfYear parameter can have the following values:
(The following are: Constant numerical description)
Vbusesystem 0 uses the regional language Support (NLS) API settings.
VbFirstJan1 1 begins on the week of January 1 (default).
vbFirstFourDays 2 begins with the first week of at least four days in the new year.
Vbfirstfullweek 3 begins with the first full week (not straddling) in the new Year.
Description: The DatePart function is used to calculate the date and return the specified time interval. For example, use DatePart to calculate the day of the week or the current time.
The FirstDayOfWeek parameter affects the calculation using the "W" and "ww" interval symbols.
If date is a date literal, the specified year becomes a fixed part of the date. However, if date is enclosed in quotation marks ("") and the year is omitted, the current year is inserted each time the date expression is evaluated in the code. This allows you to write program code that works for different years.
DateSerial function
Description: Returns a Variant of the date subtype for the specified year, month, and day.
Syntax: DateSerial (year, month, day)
Year: A numeric or numeric expression from 100 to 9999.
Month: An arbitrary numeric expression.
Day: An arbitrary numeric expression.
Note: To specify a date, such as December 31, 1991, the range of values for each parameter in the DateSerial function should be acceptable; The value of the day should be between 1 and 31, and the monthly value should be between 1 and 12. However, you can also specify a relative date for each parameter by using a numeric expression that represents the number of years, months, or days before or after a day.
The following sample uses a numeric expression instead of an absolute date. Here, the DateSerial function returns the date of 10 years (1990-10) 2 months (8-2) and one day (1-1) before August 1, 1990: May 31, 1980.
DateSerial (1990-10, 8-2, 1-1)
For the year parameter, if the value range is from 0 to 99, it is interpreted as 1900-1999 years. For year parameters outside of this range, four-digit numbers are used to represent years (for example, 1800).
When the value of any parameter exceeds an acceptable range, it is appropriately rounded to the next larger time unit. For example, if you specify 35 days, the number of days is interpreted as a month plus extra days, depending on the year and month. However, an error occurs if the parameter value exceeds the range of 32,768 to 32,767, or if the date specified by three parameters, whether directly or through an expression, is outside the acceptable date range.
Current 1/2 page
12 Next read the full text