Time and Date Functions
Functions | |
---|---|
AddDay(), AddMonth() and AddYear() | FromEpochMs() |
Age() | LocalToUtc() |
DateAdd() | Now() |
DateDiff() | ToEpochMs() |
DayOfWeek() | Today() |
EOM() | UtcToLocal() |
Function AddDay(), AddMonth() and AddYear()
Returns a date that is the result of adding days, months or years to a particular date.
Syntax
AddDay( d, n )
AddMonth( d, n )
AddYear( d, n )
Parameter | Description |
---|---|
d | Date value for addition. If this value is hard-coded it must be prefixed and suffixed with a hash (#) character, e.g. #25/12/2023#. |
n | Number of units to be added, for example, 14 days |
Date formats must use upper case M for month as lower case m refers to the minute value
Function Age()
Returns the current age or age of someone on a particular date.
Syntax
Age( d )
AgeOn( d, td )
Parameter | Description |
---|---|
d | Date value |
td | Target Date value |
Function DateAdd()
Returns a date that is the result of adding days, months or years to a particular date.
Syntax
DateAdd( t, n, d )
Parameter | Description |
---|---|
t | Time interval for comparison, e.g. years. Valid values: Day = 4 DayOfYear = 3 Month = 2 Quarter = 1 Weekday = 6 WeekOfYear = 5 Year = 0 Hour = 7 Minute = 8 Second = 9 |
n | Number of units to be added e.g. 14 days |
d | Date value for addition. If this value is hard-coded it must be prefixed and suffixed with a hash (#) character, e.g. #25/12/2020#. |
Function DateDiff()
Returns the number of days, months or years between two date/time values.
Syntax
DateDiff ( t, d1, d2 [, a] [, w] )
Parameters | Description |
---|---|
t | Time interval for comparison, e.g. years. Valid values: Day = 4 DayOfYear = 3 Hour = 7 Minute = 8 Month = 2 Quarter = 1 Second = 9 Weekday = 6 WeekOfYear = 5 Year = 0 |
d1 | First date/time value for comparison. If this value is hard-coded must be prefixed and suffixed with a hash (#) character, e.g. #31/1/2020#. |
d2 | Second date/time value for comparison. If this value is hard-coded it must be prefixed and suffixed with a hash (#) character, e.g. #31/1/2006#. |
a | (Optional) 1 to enforce the return value is positive, i.e. return absolute. 0 or leave out to return positive or negative values based on whether d1 is greater than d2. Note that you must include this parameter if you wish to use any following parameter. |
w | (Optional) 1 to compare whole units (works for years or months). For example, in an age calculation based on date of birth and current date, if the subject has not had their birthday yet this year a simple DateDiff calculation would return a result 1 year older than their age. Setting this parameter to 1 will avoid this issue. |
Notes
If the first date/time value is later than the second date/time, a negative difference will be returned. For this reason, the first date should be considered the start date, and the second date the end date.
The Absolute parameter may be used to ensure the difference is always returned as a positive number.
Function DayOfWeek()
Returns the enum value for the Day of the Week corresponding to the date.
Enum | Value |
---|---|
1 | Monday |
2 | Tuesday |
3 | Wednesday |
4 | Thursday |
5 | Friday |
6 | Saturday |
7 | Sunday |
Syntax
DayOfWeek( date )
Parameter | Description |
---|---|
d | Date value |
Function EOM()
In some documents, particularly contracts, it is necessary to calculate the last day of the month. Function EOM() returns the last day of the month of a particular date.
Syntax
EOM( d )
Parameter | Description |
---|---|
d | Date value |
Function FromEpochMs()
The From Epoch MS formula converts an epoch value in milliseconds to a universal date.
Syntax
FromEpochMs(epochMsValue)
Parameter | Description |
---|---|
epochMsValue | Epoch value in milliseconds |
Function LocalToUtc()
Converts the specified date from local to UTC
Syntax
LocalToUtc(d)
Parameter | Description |
---|---|
d | Date value for conversion. If this value is hard-coded it must be prefixed and suffixed with a hash (#) character, for example #25/12/2020#. |
Function Now()
The now() function returns the current date and time, useful for time stamping. When referenced directly it returns the web server's local time, for example 17/02/2020 4:41:21 PM.
Syntax
now()
Function ToEpochMs()
The ToEpochMS formula converts a given date to an epoch format in milliseconds. If the date is a local date, < converts it to the user's local time zone. If not, it will convert the date according to the user’s system configuration.
Syntax
ToEpochMs(date)
Parameters | Description |
---|---|
epochMsValue | Epoch value in milliseconds |
Function Today()
Returns the current date, for example 17/02/2020
Syntax
Today()
Function UtcToLocal()
Converts the specified date from UTC to local
Syntax
UtcToLocal (d)
Parameter | Description |
---|---|
d | Date value for conversion. If this value is hard-coded it must be prefixed and suffixed with a hash (#) character, for example #25/12/2020#. |
Updated 4 months ago