1. Docs
  2. Formulas
  3. Functions

DATE

Takes a date, represented by a string, an integer, or a DATE_PARSE object, and returns a formatted string representation.

The output format is defined in ruby strftime (Time) syntax.

Optionally, the output timezone can be specified with values from the tz database.

Natural language parsing is handled by chronic. It doesn't understand every phrase, and it misreads some (like "end of the month") instead of rejecting them, so test natural-language input before relying on it, or use DATE_PARSE to define the format explicitly.

Ambiguous dates like "01/02/2023" are read as DD/MM/YYYY. When the input describes a span of time, like "May 2024", DATE uses its start. Input that can't be parsed is returned unchanged.

Categories: Dates/Times

Syntax

DATE(date, format, timezone)

Examples

Example 1

Formula

DATE("2022-07-17", "%a, %b %d, %y")

Output

"Sun, Jul 17, 22"

Example 2

Formula

DATE("2021-07-17", "%Y")

Output

"2021"

Example 3: Takes DATE_PARSE objects

Formula

DATE(DATE_PARSE("05/04/1994", "%d/%m/%Y"), "%B %-d, %Y")

Output

"April 5, 1994"

Example 4: Many different representations of dates are supported

Formula

DATE("March 17, 2021", "%b %d, %y")

Output

"Mar 17, 21"

Example 5: Natural language dates are supported. See [chronic](https://github.com/mojombo/chronic#examples) for more examples.

Formula

DATE("fourteenth of May 2024", "%Y-%m-%d")

Output

"2024-05-14"

Example 6: Relative times are supported. See [chronic](https://github.com/mojombo/chronic#examples) for more examples.

Formula

DATE("tomorrow at 10am", "%Y-%m-%d %H:%M:%S")

Output

"2023-05-22 10:00:00"

Example 7: Unix timestamps are supported

Formula

DATE(1647712411, "%Y-%m-%dT%H:%M:%S")

Output

"2022-03-19T17:53:31"

Example 8: Unix timestamps with 13+ digits are treated as milliseconds

Formula

DATE(1687450077063, "%Y-%m-%dT%H:%M:%S.%L")

Output

"2023-06-22T16:07:57.063"

Example 9: To get the current time, pass the keyword `"now"` (or `"today"`)

Formula

DATE("now", "%Y-%m-%d %H:%M")

Output

"2022-03-11 16:24"

Example 10: Defaults to iso8601 format with three decimal places if no format is provided

Formula

DATE("now")

Output

"2022-03-11T16:24:01.123Z"

Example 11: Takes optional timezone argument

Formula

DATE("2023-05-19 12pm", "%Y-%m-%d %H:%M:%S %Z", "Asia/Tokyo")

Output

"2023-05-19 21:00:00 JST"

Example 12: Ambiguous dates are read as DD/MM/YYYY

Formula

DATE("01/02/2023", "%B %-d, %Y")

Output

"February 1, 2023"

Example 13: When the input describes a span of time, like a month, DATE uses its start

Formula

DATE("May 2024", "%Y-%m-%d %H:%M")

Output

"2024-05-01 00:00"

Example 14: Input that can't be parsed is returned unchanged

Formula

DATE("not a date", "%Y-%m-%d")

Output

"not a date"

Sample actions

Event Transform
DATE
Event Transform
My Action

Select an action to inspect

You can also click "Copy actions" and paste them in your Tines story to see how they work.

Was this helpful?