Date

The Date Data Type is used to represent a calendar date, which consists of three sets of numbers representing a year, a month, and a day.

Structure

Date is an object with the following properties:

  • day (number) - the day of a month, where indexing begins at 1 with January

  • month (number) - the month of a year, where 1 represents January, whereas 12 represents December

  • year (number) - a year

Examples

Dates can be created using the DATE function which takes the year, month, and day as arguments. For example, a Date for September 18th, 2017 can be created by calling the DATE function with the arguments 2017, 9, 18, respectively.

DATE(2017, 9, 18) -> {"day": 18,  
    "month": 9,  
    "year": 2017 } 

Now, assuming we have an example_date variable holding the date above, let's use the FORMAT_DATE to format the date into the string "September 18th, 2017":

FORMAT_DATE(  
  example_date,   
  "MMMM Mo, YYYY"
) -> "September 18th, 2017"

As with FORMAT_DATETIME, when called with no format string, FORMAT_DATE will generate an ISO 8601 and RFC3339 compatible timestamp. The time portion of the timestamp will be filled with zeros.

FORMAT_DATE(example_date) -> "2007-01-09T00:00:00Z"

Last updated