Date Functions¶
DateAdd¶
Description
Returns a date with a time or date interval added to it.
Syntax
Arguments
- interval
- The interval to add. It can be one of the following values:
| Interval | Explanation |
|---|---|
| yyyy | Year |
| Q | Quarter |
| m | Month |
| Y | Day of Year |
| D | Day |
| w | Weekday |
| ww | Week |
| H | Hour |
| N | Minute |
| S | Second |
- number
- The number of intervals to add.
- date
- The date to add the interval to.
DateDiff¶
Description
Returns the difference between two dates, in the interval you specify.
Syntax
Arguments
- interval
- The interval of time to use to calculate the difference between date1 and date2.
- The valid interval values are:
| Interval | Explanation |
|---|---|
| yyyy | Year |
| q | Quarter |
| m | Month |
| y | Day of Year |
| d | Day |
| w | Weekday |
| ww | Week |
| h | Hour |
| n | Minute |
| s | Second |
- date1 and date2
- The two dates to calculate the difference between.
- firstdayofweek
- Optional. A constant that specifies the first day of the week. If omitted, the function assumes that Sunday is the first day of the week.
- firstweekofyear
- Optional. A constant that specifies the first week of the year. If omitted, the function assumes that the week containing 1 January is the first week of the year.
DatePart¶
Description
Returns a specified part of a given date.
Syntax
Arguments
- interval
- The interval to return. It can be one of the following values:
| Interval | Explanation |
|---|---|
| yyyy | Year |
| Q | Quarter |
| m | Month |
| Y | Day of Year |
| D | Day |
| w | Weekday |
| ww | Week |
| H | Hour |
| N | Minute |
| S | Second |
- date
- The date to evaluate.
- firstdayofweek
- Optional. A constant that specifies the first day of the week. If omitted, the function assumes that Sunday is the first day of the week. It can be one of the following values:
| Value | Explanation |
|---|---|
| 0 | Use the NLS API setting |
| 1 | Sunday (default) |
| 2 | Monday |
| 3 | Tuesday |
| 4 | Wednesday |
| 5 | Thursday |
| 6 | Friday |
| 7 | Saturday |
- firstweekofyear
- Optional. A constant that specifies the first week of the year. If omitted, the function assumes that the week containing 1 January is the first week of the year. It can be one of the following values:
| Value | Explanation |
|---|---|
| 0 | Use the NLS API setting |
| 1 | Use the first week that includes 1 January (default) |
| 2 | Use the first week in the year that has at least 4 days |
| 3 | Use the first full week of the year |
DateSerial¶
Description
Returns a date from a year, a month and a day.
Syntax
Arguments
- year
- A number between 100 and 9999 that gives the year.
- month
- A number that gives the month.
- day
- A number that gives the day.
DateValue¶
Description
Returns the serial number of a date.
Syntax
Arguments
- date
- A string representation of a date.
Day¶
Description
Returns the day of the month (a number from 1 to 31) of a date.
Syntax
Arguments
- date
- Must be a valid date.
Hour¶
Description
Returns the hour of a time value (from 0 to 23).
Syntax
Arguments
- time
- The time value to extract the hour from. It can be a string, a decimal number or the result of a formula.
ISO8601ToDate¶
Description
Converts a string holding an ISO 8601 date and time to a date/time value.
Syntax
Arguments
- isodate
- A string in one of these formats:
- Complete Date
YYYY-MM-DD(for example,1997-07-16)
- Complete Date plus hours and minutes
YYYY-MM-DDThh:mmTZD(for example,1997-07-16T19:20+01:00)
- Complete Date plus hours, minutes and seconds
YYYY-MM-DDThh:mm:ssTZD(for example,1997-07-16T19:20:30+01:00)
- Complete Date plus hours, minutes, seconds and a decimal fraction of a second
YYYY-MM-DDThh:mm:ss.sTZD(for example,1997-07-16T19:20:30.45+01:00)
- Complete Date
- Where:
- A string in one of these formats:
| YYYY | four-digit year |
|---|---|
| MM | two-digit month (01=January, etc.) |
| DD | two-digit day of month (01 through 31) |
| hh | two digits of hour (00 through 23) (am/pm not allowed) |
| mm | two digits of minute (00 through 59) |
| ss | two digits of second (00 through 59) |
| s | one or more digits representing a decimal fraction of a second |
| TZD | Time zone designator (Z or +hh:mm or -hh:mm) |
Example
' IMan-specific, and the one to be careful with. It
' accepts anything the .NET date parser accepts -- not
' strictly ISO 8601 -- and always converts the result to
' the IMan SERVER's local time.
'
' So a value carrying an offset or a trailing Z is
' shifted into server time, and a value carrying NO
' timezone is treated as UTC and shifted anyway. On a
' UTC server both are no-ops; elsewhere they are not.
ISO8601ToDate("2026-03-12T09:35:00Z") ' 09:35 UTC in server time
ISO8601ToDate("2026-03-12T09:35:00+02:00") ' 07:35 UTC in server time
IsDate¶
Description
Returns True if the expression is a valid date, and False if it is not.
Syntax
Arguments
- expression
- A variant.
LastDayInMonth¶
Description
Returns the day number of the last day in the month, that is, the number of days the month has. The return value is an integer between 28 and 31.
Syntax
Arguments
- month
- An integer between 1 and 12 representing the month.
- year
- A valid year.
Example
' IMan-specific. Note the arguments: the MONTH first and
' the YEAR second, not a date. It returns a day number,
' so it is really a month-length function.
LastDayInMonth(3, 2026) ' Returns 31
LastDayInMonth(2, 2026) ' Returns 28 -- 2026 is not a leap year
' To get the date itself, build it:
DateSerial(Year(%OrdDate), Month(%OrdDate), LastDayInMonth(Month(%OrdDate), Year(%OrdDate)))
' 12/03/2026 returns 31/03/2026
LocalToUTCTime¶
Description
Converts a local time to UTC time.
Syntax
Arguments
- date
- The local date/time to convert to UTC.
Minute¶
Description
Returns the minute of a time value (from 0 to 59).
Syntax
Arguments
- time
- The time value to extract the minute from. It can be a string, a decimal number or the result of a formula.
Month¶
Description
Returns the month (a number from 1 to 12) given a date value.
Syntax
Arguments
- date_value
- A valid date.
MonthName¶
Description
Returns the name of the month for a number from 1 to 12.
Syntax
Arguments
- number
- A value from 1 to 12, representing the month.
- abbreviate
- Optional. A Boolean, True or False.
- If True, MonthName abbreviates the month name.
- If False, MonthName returns the name in full.
NumberToDate¶
Description
Returns a date from a number in the format yyyymmdd.
Syntax
Arguments
- number
- An integer in the format
yyyymmdd.
- An integer in the format
Example
Second¶
Description
Returns a whole number between 0 and 59, inclusive, representing the second of the minute.
Syntax
Arguments
- time
- Any expression that can represent a time. If time contains Null, Second returns Null.
TimeSerial¶
Description
Returns a time from an hour, a minute and a second.
Syntax
Arguments
- hour
- A number between 0 and 23 that gives the hour.
- minute
- A number that gives the minute.
- second
- A number that gives the second.
TimeValue¶
Description
Returns the serial number of a time.
Syntax
Arguments
- time_value
- A string representation of a time.
UTCToLocalTime¶
Description
Converts a UTC date/time to a local date/time.
Syntax
Arguments
- date
- The UTC date/time to convert to local time.
Weekday¶
Description
Returns a number for the day of the week of a date.
Syntax
Arguments
- date
- Any expression that can represent a date, such as a serial number or a date in quotation marks. If date contains Null, Weekday returns Null.
- firstdayofweek
- A constant that specifies the first day of the week. If omitted, Weekday assumes
vbSunday.
- A constant that specifies the first day of the week. If omitted, Weekday assumes
| Value | Explanation |
|---|---|
| 0 | Use the NLS API setting |
| 1 | Sunday (default) |
| 2 | Monday |
| 3 | Tuesday |
| 4 | Wednesday |
| 5 | Thursday |
| 6 | Friday |
| 7 | Saturday |
WeekdayName¶
Description
Returns the name of the day of the week for a number from 1 to 7.
Syntax
Arguments
- number
- A value from 1 to 7, representing a day of the week.
- abbreviate
- Optional. A Boolean, True or False. If True, WeekdayName abbreviates the name. If False, it returns the name in full.
- firstdayofweek
- Optional. The first day of the week. It can be one of the following values:
| Value | Explanation |
|---|---|
| 0 | Use the NLS API setting |
| 1 | Sunday (default) |
| 2 | Monday |
| 3 | Tuesday |
| 4 | Wednesday |
| 5 | Thursday |
| 6 | Friday |
| 7 | Saturday |
If firstdayofweek is omitted, WeekdayName assumes that the first day of the week is Sunday.
Year¶
Description
Returns the four-digit year (a number from 1900 to 9999) of a date.
Syntax
Arguments
- date_value
- A valid date.