Dates
A reference document listing built-in convenience functions to support data transformation in expressions for dates.
beginningOf(unit?: DurationUnit): Date
Transforms a Date to the start of the given time period. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters
unit
(OPTIONAL, STRING ENUM): A valid string specifying the time unit.
Default: week
One of: second
, minute
, hour
, day
, week
, month
, year
endOfMonth(): Date
Transforms a Date to the end of the month.
extract(datePart?: DurationUnit): Number
Extracts the part defined in datePart from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters
-
datePart
(OPTIONAL, STRING ENUM): A valid string specifying the time unit.Default:
week
One of:
second
,minute
,hour
,day
,week
,month
,year
format(fmt: TimeFormat): String
Formats a Date in the given structure.
Function parameters
-
fmt
(REQUIRED, STRING ENUM):: A valid string specifying the time format. Refer to Luxon | Table of tokens for formats.
isBetween(date1: Date | DateTime, date2: Date | DateTime): Boolean
Checks if a Date is between two given dates.
Function parameters
-
date1
(REQUIRED, DATE OR DATETIME): The first date in the range. -
date2
(REQUIRED, DATE OR DATETIME): The last date in the range.
isDst(): Boolean
Checks if a Date is within Daylight Savings Time.
isInLast(n?: Number, unit?: DurationUnit): Boolean
Checks if a Date is within a given time period.
Function parameters
-
n
(OPTIONAL, NUMBER): The number of units. For example, to check if the date is in the last nine weeks, enter 9.Default:
0
-
unit
(OPTIONAL, STRING ENUM): A valid string specifying the time unit.Default:
minutes
One of:
second
,minute
,hour
,day
,week
,month
,year
isWeekend(): Boolean
Checks if the Date falls on a Saturday or Sunday.
minus(n: Number, unit?: DurationUnit): Date
Subtracts a given time period from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters
-
n
(REQUIRED, NUMBER): The number of units. For example, to subtract nine seconds, enter 9 here. -
unit
(OPTIONAL, STRING ENUM): A valid string specifying the time unit.Default:
milliseconds
One of:
second
,minute
,hour
,day
,week
,month
,year
plus(n: Number, unit?: DurationUnit): Date
Adds a given time period to a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters
-
n
(REQUIRED, NUMBER): The number of units. For example, to add nine seconds, enter 9 here. -
unit
(OPTIONAL, STRING ENUM): A valid string specifying the time unit.Default:
milliseconds
One of:
second
,minute
,hour
,day
,week
,month
,year
toDateTime(): Date
Converts a JavaScript date to a Luxon date object.