Skip to content

Date Functions

CDate

Description

Converts a value to a date.

Syntax

CDate(expression)

Arguments

  • expression
    • Must be a valid date.

Example

' Parsed using the IMan server's locale, so "12/03/2026"
' is 12 March on a UK server and 3 December on a US one.
' Test IsDate first when the source cannot be trusted.
CDate("12/03/2026")   ' Returns 12/03/2026 on a UK server

Date

Description

Returns the current system date.

Syntax

Date

Arguments

  • None

Example

' Today's date on the IMan server, with no time
' component.
Date()   ' Returns e.g. 12/03/2026

DateAdd

Description

Returns a date with a time or date interval added to it.

Syntax

DateAdd (interval, number, date)

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.

Example

' Add an interval. Negative values subtract.
DateAdd("d", 30, %OrdDate)    ' 12/03/2026 returns 11/04/2026
DateAdd("m", 1, %OrdDate)     ' Returns 12/04/2026
DateAdd("d", -1, %OrdDate)    ' Returns 11/03/2026

DateDiff

Description

Returns the difference between two dates, in the interval you specify.

Syntax

DateDiff( interval, date1, date2, [firstdayofweek], [firstweekofyear] )

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.

Example

' Whole intervals between two dates, earlier date first.
DateDiff("d", %OrdDate, CDate("30/04/2026"))   ' Returns 49

DatePart

Description

Returns a specified part of a given date.

Syntax

DatePart( interval, date, [firstdayofweek], [firstweekofyear] )

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

Example

' One component of a date. "q" is the quarter.
DatePart("q", %OrdDate)    ' 12/03/2026 returns 1
DatePart("yyyy", %OrdDate) ' Returns 2026

DateSerial

Description

Returns a date from a year, a month and a day.

Syntax

DateSerial( year, month, day )

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.

Example

' Build a date from year, month and day. Out-of-range
' parts roll over, which is what makes day 0 useful: it
' is the last day of the month before, so this returns
' 31/03/2026 rather than erroring.
DateSerial(2026, 3, 12)   ' Returns 12/03/2026
DateSerial(2026, 4, 0)    ' Returns 31/03/2026

DateValue

Description

Returns the serial number of a date.

Syntax

DateValue( date )

Arguments

  • date
    • A string representation of a date.

Example

' Parses text to a date and discards any time component.
DateValue("12 March 2026")   ' Returns 12/03/2026

Day

Description

Returns the day of the month (a number from 1 to 31) of a date.

Syntax

Day( date )

Arguments

  • date
    • Must be a valid date.

Example

Day(%OrdDate)   ' 12/03/2026 returns 12

Hour

Description

Returns the hour of a time value (from 0 to 23).

Syntax

Hour( time )

Arguments

  • time
    • The time value to extract the hour from. It can be a string, a decimal number or the result of a formula.

Example

' 24-hour clock.
Hour(%OrdDate)   ' 12/03/2026 09:35:00 returns 9

ISO8601ToDate

Description

Converts a string holding an ISO 8601 date and time to a date/time value.

Syntax

ISO8601ToDate ( isodate )

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)
    • Where:
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

IsDate( expression )

Arguments

  • expression
    • A variant.

Example

' Guard a cast against text that will not parse.
Dim OrderDate
OrderDate = ""
If IsDate(%OrdDate) Then OrderDate = CDate(%OrdDate)
OrderDate   ' "TBC" returns "", which leaves the target field with no value

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

LastDayInMonth( month, year )

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

LocalToUTCTime( date )

Arguments

  • date
    • The local date/time to convert to UTC.

Example

' IMan-specific. Converts from the IMan SERVER's
' timezone to UTC -- the server's, not the customer's
' and not the connector's. Use it when a webservice
' expects UTC timestamps.
LocalToUTCTime(%OrdDate)   ' 09:35 on a UTC+1 server returns 08:35

Minute

Description

Returns the minute of a time value (from 0 to 59).

Syntax

Minute( time )

Arguments

  • time
    • The time value to extract the minute from. It can be a string, a decimal number or the result of a formula.

Example

Minute(%OrdDate)   ' 12/03/2026 09:35:00 returns 35

Month

Description

Returns the month (a number from 1 to 12) given a date value.

Syntax

Month( date_value )

Arguments

  • date_value
    • A valid date.

Example

Month(%OrdDate)   ' 12/03/2026 returns 3

MonthName

Description

Returns the name of the month for a number from 1 to 12.

Syntax

MonthName( number, [ abbreviate ] )

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.

Example

' Pass True as the second argument to abbreviate.
MonthName(Month(%OrdDate))         ' Returns "March"
MonthName(Month(%OrdDate), True)   ' Returns "Mar"

Now

Description

Returns the current system date and time.

Syntax

Now

Arguments

  • None

Example

' Date and time on the IMan server.
Now()   ' Returns e.g. 12/03/2026 09:35:00

NumberToDate

Description

Returns a date from a number in the format yyyymmdd.

Syntax

NumberToDate( number )

Arguments

  • number
    • An integer in the format yyyymmdd.

Example

' IMan-specific. The number must be yyyyMMdd and exactly
' eight digits -- it is NOT an OLE serial date or a Unix
' timestamp. Anything else raises an out-of-range error,
' except null or 0, which return 01/01/1900.
NumberToDate(20260312)   ' Returns 12/03/2026
NumberToDate(0)          ' Returns 01/01/1900

Second

Description

Returns a whole number between 0 and 59, inclusive, representing the second of the minute.

Syntax

Second ( time )

Arguments

  • time
    • Any expression that can represent a time. If time contains Null, Second returns Null.

Example

Second(%OrdDate)   ' 12/03/2026 09:35:00 returns 0

Time

Description

Returns the current system time.

Syntax

Time

Arguments

  • None

Example

' The time of day on the IMan server, with no date
' component.
Time()   ' Returns e.g. 09:35:00

Timer

Description

Returns the number of seconds since midnight.

Syntax

Timer

Arguments

  • None

Example

' Seconds elapsed since midnight, to a fraction. For
' timing a step, not for stamping a record.
Timer()   ' Returns e.g. 34500.13

TimeSerial

Description

Returns a time from an hour, a minute and a second.

Syntax

TimeSerial( hour, minute, second )

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.

Example

TimeSerial(9, 35, 0)   ' Returns 09:35:00

TimeValue

Description

Returns the serial number of a time.

Syntax

TimeValue( time_value )

Arguments

  • time_value
    • A string representation of a time.

Example

' Parses text to a time and discards any date component.
TimeValue("09:35:00")   ' Returns 09:35:00

UTCToLocalTime

Description

Converts a UTC date/time to a local date/time.

Syntax

UTCToLocalTime( date )

Arguments

  • date
    • The UTC date/time to convert to local time.

Example

' IMan-specific. Converts a UTC value into the IMan
' SERVER's timezone -- the server's, not the customer's.
' Use it on timestamps arriving from a webservice that
' returns UTC.
UTCToLocalTime(%OrdDate)   ' 08:35 UTC on a UTC+1 server returns 09:35

Weekday

Description

Returns a number for the day of the week of a date.

Syntax

Weekday( date, firstdayofweek )

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.
Value Explanation
0 Use the NLS API setting
1 Sunday (default)
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday

Example

' 1 to 7, Sunday being 1 by default. Pass 2 as the
' second argument to start the week on Monday.
Weekday(%OrdDate)      ' 12/03/2026 is a Thursday, so returns 5
Weekday(%OrdDate, 2)   ' Week starting Monday, so returns 4

WeekdayName

Description

Returns the name of the day of the week for a number from 1 to 7.

Syntax

WeekdayName( number, [ abbreviate], [ firstdayofweek ] )

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.

Example

' Pass True as the second argument to abbreviate.
WeekdayName(Weekday(%OrdDate))         ' Returns "Thursday"
WeekdayName(Weekday(%OrdDate), True)   ' Returns "Thu"

Year

Description

Returns the four-digit year (a number from 1900 to 9999) of a date.

Syntax

Year( date_value )

Arguments

  • date_value
    • A valid date.

Example

Year(%OrdDate)   ' 12/03/2026 returns 2026