DateTime

◷ Reading Time: 5 minutes

today

Returns the local date for today.

 today ()
Example: today () 
Result: 8/12/2020 12:00:00 AM

Returns today's date. Time will always be 12:00:00 AM.

todayUtc

Returns today’s date in Coordinated Universal Time (UTC).

 todayUtc ()
Example: todayUtc () 
Result: 7/12/2020 12:00:00 AM

Returns today's UTC date. Time will always be 12:00:00 AM.

now

Returns the local date and time now.

 now ()
Example: now () 
Result: 8/12/2020 10:11:22 AM

Returns today's date including the time.

nowUtc

Returns local date and time now based on Coordinated Universal Time (UTC).

 nowUtc ()
Example: nowUtc () 
Result: 7/12/2020 11:12:41 PM

Returns today's UTC date including the time.

date

Builds a local date and time with different components.

 date (year, month, day, hour, minute, second, millisecond)
  • year (Integer): Year of the date (Mandatory)
  • month (Integer): Month of the date (Mandatory)
  • day (Integer): Day of the date (Mandatory)
  • hour (Integer): Hour of the date (Optional)
  • minute (Integer): Minute of the date (Optional)
  • second (Integer): Second of the date (Optional)
  • millisecond (Integer): Millisecond of the date (Optional)
Example: date (2020, 10, 01, 10, 55, 52, 2) 
Result: 1/10/2020 10:55:52 AM
Example: date (2020, 10, 01, 21, 55, 52, 2) 
Result: 1/10/2020 9:55:52 PM
Example: date (2020, 10, 01) 
Result: 1/10/2020 12:00:00 AM

isDate

Validates a string can be formatted as a date

 isDate (value, formatter)
  • value (String): Value that presents a date (Mandatory)
  • formatted (String): Valid list of date and time formatter (Mandatory)
DateTime format specifier
Below is the list of formatted:

Year
y: The year, from 0 to 99
yy: The year, from 00 to 99
yyy: The year, with a minimum of three digits
yyyy: The year as a four-digit number

Month
M: The month, from 1 through 12
MM: The month, from 01 through 12
MMM: The abbreviated name of the month
MMMM: The full name of the month

Day
d: The day of the month, from 1 through 31
dd: The day of the month, from 01 through 31
ddd: The day of the month, from 01 through 31
dddd: The full name of the day of the week

Hour
h: The hour, using a 12-hour clock from 1 to 12
hh: The hour, using a 12-hour clock from 01 to 12
H: The hour, using a 24-hour clock from 0 to 23
HH: The hour, using a 24-hour clock from 00 to 23

Minute
m: The minute, from 0 through 59
mm: The minute, from 00 through 59

Second
s: The second, from 0 through 59
ss: The second, from 00 through 59

AM/PM
t: The first character of the AM/PM designator
tt: The AM/PM designator

For example: MM/dd/YYYY shows the abbreviated name of the month, the day of the month, from 01 through 31 and the year as a four-digit number separated with /
Example: isDate ('4/12/2020','d/MM/yyyy') 
Result: True
Example: isDate ('4/12/2020') 
Result: True
Example: isDate ('4/12/2020 12:00:00 AM','d/MM/yyyy hh:mm:ss tt') 
Result: True
Example: isDate ('4/12/2020 12:00:00 AM','d/MM/yyyy') 
Result: False

dateUtc

Builds a date and time with different components based on Coordinated Universal Time (UTC).

 dateUtc (year, month, day, hour, minute, second, millisecond)
  • year (Integer): Year of the date (Mandatory)
  • month (Integer): Month of the date (Mandatory)
  • day (Integer): Day of the date (Mandatory)
  • hour (Integer): Hour of the date (Optional)
  • minute (Integer): Minute of the date (Optional)
  • second (Integer): Second of the date (Optional)
  • millisecond (Integer): Millisecond of the date (Optional)
Example: dateUtc (2020, 10, 01, 10, 55, 52, 2) 
Result: 1/10/2020 10:55:52 AM
Example: dateUtc (2020, 10, 01, 21, 55, 52, 2) 
Result: 1/10/2020 9:55:52 PM
Example: dateUtc (2020, 10, 01) 
Result: 1/10/2020 12:00:00 AM

dateDiff

Returns the time between two dates based on an interval.

 dateDiff (interval, date1, date2)
  • interval (String): Years, months, weeks, days, hours, minutes, seconds, milliseconds, offset (Mandatory)
  • date1 (DateTime): Beginning date (Mandatory)
  • date2 (DateTime): End date (Mandatory)

dateDiff would calculate date1-date2 expression agnostically. When offset is selected for the interval, the result is an array of values for [days, hours, minutes, seconds, milliseconds] otherwise the value is a number.

Example: dateDiff ('years', #1/10/2019 12:00:00 AM#, #1/10/2018 12:00:00 AM#)
Result: 1
Example: dateDiff ('years', #1/10/2018 12:00:00 AM#, #1/10/2019 12:00:00 AM#)
Result: -1
Example: dateDiff ('months', today(), #1/10/2019 12:00:00 AM#)
Result: 14.2684931506849

Time difference in months beween today and 1/10/2019 12:00:00 AM 
Example: dateDiff ('offset', today(), #1/10/2020 12:00:00 AM#)

Result: 
[
     68,
     0,
     0,
     0,
     0
 ]

dateAdd

Adds a slot of time to a date based on an interval and returns the new date/time.

 dateAdd (interval, date, value)
  • interval (String): Years, months, days, hours, minutes, seconds, milliseconds (Mandatory)
  • date ( DateTime ): Beginning date (Mandatory)
  • value (Integer): Value to be added to the date (Mandatory)
Example: dateAdd ('years', #1/10/2019 12:00:00 AM#, 5) 
Result: 1/10/2024 12:00:00 AM
Example: dateAdd ('years', #1/10/2021#, -5) 
Result: 1/10/2016 12:00:00 AM
Example: dateAdd ('months', today(), 2) 
Result: 8/02/2021 12:00:00 AM

Adds 2 months to today's date

dateCalendar

Returns the list of calendar’s dates in DateTime between two given dates.

 dateCalendar (date1, date2)
  • date1(DateTime): Beginning date (Mandatory)
  • date2(DateTime): Ending date (Mandatory)
Example: dateCalendar (date(2022,08,28), today()) 
Result: Returns a date calendar with different components in between 2022,08,28 and today.

datePart

Returns a specific part of a date object based on the interval value.

 dateName (interval, date)
  • interval(String): years, months, weeks, days, hours, minutes, seconds, milliseconds, offset.(Mandatory)
  • date(DateTime): (Mandatory)

dateName

Returns a specific part of a date object based on the interval value. It is similar to datePart however the values for months, days and offset will be translated to their names.

 dateName (interval, date)
  • interval(String): years, months, weeks, days, hours, minutes, seconds, milliseconds, offset (Mandatory)
  • date(DateTime): (Mandatory)
Example: dateName ('Months', today()) 
Result: This will return today’s month.
Example: dateName ('days', today()) 
Result: This will return today’s day. 

dateDays

This will return the days in a given month of the year.

 dateDays (year, month)
  • year(Integer): (Mandatory)
  • month(Integer): (Mandatory)
Example: dateDays (2021, 09)
Result: 30
Example: dateDays (2020, 02) 
Result: 29
Updated on October 7, 2022

Was this article helpful?

Related Articles