Creating dates

newDate

Creates a DateTime with the specified day, month, and year.

Usage

newDate(<day>, <month>, <year>)

Parameters

NameTypeRequiredDescription
daynumberYesA number between 1 and the maximum number of days in the specified month, representing the day.
monthnumberYesA number between 1 and 12, representing the month.
yearnumberYesA number between 1 and 9999, representing the year.

Returns

A new DateTime with the specified date and the time set to 00:00:00.

Examples

ExpressionResult
newDate(1, 1, 2021)1 Jan 2021 00:00:00
newDate(31, 3, 2000)31 March 2000 00:00:00

newDateTime

Creates a DateTime with the specified day, month, and year, hour, minute, and second.

Usage

newDateTime(<day>, <month>, <year>, <hour>, <minute>, <second>)

Parameters

NameTypeRequiredDescription
daynumberYesA number between 1 and the maximum number of days in the specified month, representing the day.
monthnumberYesA number between 1 and 12, representing the month.
yearnumberYesA number between 1 and 9999, representing the year.
hournumberYesA number between 1 and 24, representing the hour.
minutenumberYesA number between 1 and 60, representing the minute.
secondnumberYesA number between 1 and 60, representing the second.

Returns

A new DateTime with the specified date and time.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0)1 Jan 2021 00:00:00
newDateTime(31, 3, 2000, 10, 59)31 March 2000 10:11:59

utcNow

Creates a DateTime set to the current Coordinated Universal Time (UTC).

Usage

utcNow()

Returns

A new DateTime set to the current Coordinated Universal Time (UTC).

Examples

ExpressionResult
utcNow()20 Sept 2021 10:11:59

Manipulating dates

addDays

Adds the specified number of days to a DateTime.

Usage

<datetime>.addDays(<days>)

Parameters

NameTypeRequiredDescription
daysnumberYesThe number of days to add to the DateTime. The number can be positive, negative, and/or fractional.

Returns

A new DateTime with the specified number of days added.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).addDays(3)3 Jan 2021 00:00:00
newDateTime(30, 3, 2000, 11, 10, 43).addDays(3)2 April 2000 11:10:43

addHours

Adds the specified number of hours to a DateTime.

Usage

<datetime>.addHours(<hours>)

Parameters

NameTypeRequiredDescription
hoursnumberYesThe number of hours to add to the DateTime. The number can be positive, negative, and/or fractional.

Returns

A new DateTime with the specified number of hours added.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).addHours(3)1 Jan 2021 03:00:00
newDateTime(30, 3, 2000, 11, 10, 43).addHours(25)31 March 2000 12:10:43

addMinutes

Adds the specified number of minutes to a DateTime.

Usage

<datetime>.addMinutes(<minutes>)

Parameters

NameTypeRequiredDescription
minutesnumberYesThe number of minutes to add to the DateTime. The number can be positive, negative, and/or fractional.

Returns

A new DateTime with the specified number of minutes added.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).addMinutes(3)1 Jan 2021 00:03:00
newDateTime(30, 3, 2000, 11, 10, 43).addMinutes(65)30 March 2000 12:15:43

addMonths

Adds the specified number of months to a DateTime.

Usage

<datetime>.addMonths(<months>)

Parameters

NameTypeRequiredDescription
monthsnumberYesThe number of months to add to the DateTime. The number can be positive or negative, but not fractional.

Returns

A new DateTime with the specific number of months added.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).addMonths(3)1 May 2021 00:00:00
newDateTime(30, 3, 2000, 11, 10, 43).addMonths(13)30 April 2001 11:10:43

addSeconds

Adds the specified number of seconds to a DateTime.

Usage

<datetime>.addSeconds(<seconds>)

Parameters

NameTypeRequiredDescription
secondsnumberYesThe number of seconds to add to the DateTime. The number can be positive, negative, and/or fractional.

Returns

A new DateTime with the specified number of seconds added.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).addSeconds(3)1 Jan 2021 00:00:03
newDateTime(30, 3, 2000, 11, 10, 43).addSeconds(65)30 March 2000 11:11:48

addYears

Adds the specified number of years to a DateTime.

Usage

<datetime>.addYears(<years>)

Parameters

NameTypeRequiredDescription
yearsnumberYesThe number of years to add to the DateTime. The number can be positive or negative, but not fractional.

Returns

A new DateTime with the specified number of years added.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).addYears(3)1 January 2024 00:00:00
newDateTime(30, 3, 2000, 11, 10, 43).addYears(3)30 March 2003 11:10:43

Reading dates

date

Gets the date from a DateTime.

Usage

<datetime>.date()

Returns

A new DateTime that has the same date as the original DateTime and its time set to midnight (00:00:00).

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).date()1 Jan 2021
newDateTime(30, 3, 2000, 11, 10, 43).date()30 March 2000

day

Gets the day from a DateTime.

Usage

<datetime>.day()

Returns

A number between 1 and 31, representing a day of the month.

Examples

ExpressionResult
newDate(1, 1, 2021).day()1
newDate(31, 3, 2000).day()31

dayOfWeek

Gets the day of the week from a DateTime.

Usage

<datetime>.dayOfWeek()

Returns

A number between 0 and 6, with 0 representing Sunday and 6 representing Saturday.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).dayOfWeek()5
newDateTime(30, 3, 2000, 11, 10, 43).dayOfWeek()4

hour

Gets the hour from a DateTime.

Usage

<datetime>.hour()

Returns

A number between 1 and 24, representing an hour.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).hour()0
newDateTime(31, 3, 2000, 11, 10, 43).hour()11

minute

Gets the minute from a DateTime.

Usage

<datetime>.minute()

Returns

A number between 1 and 60, representing a minute.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).minute()0
newDateTime(31, 3, 2000, 11, 10, 43).minute()10

month

Gets the month from a DateTime.

Usage

<datetime>.month()

Returns

A number between 1 and 60, representing a month.

Examples

ExpressionResult
newDate(1, 1, 2021).month()1
newDate(31, 3, 2000).month()3

second

Gets the second from a DateTime.

Usage

<datetime>.second()

Returns

A number between 1 and 60, representing a second.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).second()0
newDateTime(31, 3, 2000, 11, 10, 43).second()43

year

Gets the year from a DateTime.

Usage

<datetime>.year()

Returns

A number between 1 and 9999, representing a year.

Examples

ExpressionResult
newDate(1, 1, 2021).year()2021
newDate(31, 3, 2000).year()2000

Comparing dates

diffDays

Gets the difference between two DateTimes, in days.

Usage

<first_datetime>.diffDays(<second_datetime>)

Parameters

NameTypeRequiredDescription
datetimeDateTimeYesThe DateTime to compare with.

Returns

The number of days between the two DateTime values. This number can be positive, negative, and/or fractional.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).diffDays(newDateTime(3, 1, 2021, 0, 0, 0))2
newDateTime(1, 1, 2021, 0, 0, 0).diffDays(newDateTime(5, 2, 2020, 5, 40, 13))-330.763

diffHours

Gets the difference between two DateTimes, in hours.

Usage

<first_datetime>.diffHours(<second_datetime>)

Parameters

NameTypeRequiredDescription
datetimeDateTimeYesThe DateTime to compare with.

Returns

The number of hours between the two DateTime values. This number can be positive, negative, and/or fractional.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).diffHours(newDateTime(3, 1, 2021, 0, 0, 0))48
newDateTime(1, 1, 2021, 0, 0, 0).diffHours(newDateTime(5, 2, 2020, 5, 40, 13))-7938.329

diffMinutes

Gets the difference between two DateTimes, in minutes.

Usage

<first_datetime>.diffMinutes(<second_datetime>)

Parameters

NameTypeRequiredDescription
datetimeDateTimeYesThe DateTime to compare with.

Returns

The number of minutes between the two DateTime values. This number can be positive, negative, and/or fractional.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).diffMinutes(newDateTime(3, 1, 2021, 0, 0, 0))2880
newDateTime(1, 1, 2021, 0, 0, 0).diffMinutes(newDateTime(31, 12, 2020, 5, 40, 13))-1099.783

diffSeconds

Gets the difference between two DateTimes, in seconds..

Usage

<first_datetime>.diffSeconds(<second_datetime>)

Parameters

NameTypeRequiredDescription
datetimeDateTimeYesThe DateTime to compare with.

Returns

The number of seconds between the two DateTime values. This number can be positive, negative, and/or fractional.

Examples

ExpressionResult
newDateTime(1, 1, 2021, 0, 0, 0).diffSeconds(newDateTime(3, 1, 2021, 0, 0, 0))172800
newDateTime(1, 1, 2021, 0, 0, 0).diffSeconds(newDateTime(31, 12, 2020, 5, 40, 13))-65986.98