Format Date directive

The FORMAT-DATE directive formats CDAP timestamp_micros values to custom pattern strings.

To convert strings to timestamp_micros values, see PARSE-AS-SIMPLE-DATE.

To convert timestamp columns to date columns, see Converting Timestamp types to Date.


format-date :column 'format'

Usage Notes

Date and time formats are specified by date and time pattern strings. Within pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. Two single quotes '' represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.

Supported Patterns for Formatting and Parsing

CDAP supports the Java SimpleDateFormat patterns for formatting and parsing datetime values. For more information about the SimpleDateFormat patterns, see the SimpleDateFormat documentation.

Date and Time Pattern Examples

Prior to using these patterns, the directive PARSE-AS-SIMPLEDATE must be applied to correctly create a complete timestamp_micros value.

These examples show how date and time patterns are interpreted in the U.S. locale. If the given date and time is 2001-07-04 12:08:56, and is a local time in the U.S. Pacific Time Zone, then applying different patterns results in these strings:

Date and Time Pattern

Date String

Date and Time Pattern

Date String

yyyy.MM.dd G 'at' HH:mm:ss z

2001.07.04 AD at 12:08:56 PDT

EEE, MMM d, ''yy

Wed, Jul 4, '01

h:mm a

12:08 PM

hh 'o''clock' a, zzzz

12 o'clock PM, Pacific Daylight Time

K:mm a, z

0:08 PM, PDT

yyyy.MMMMM.dd GGG hh:mm aaa

2001.July.04 AD 12:08 PM

EEE, d MMM yyyy HH:mm:ss Z

Wed, 4 Jul 2001 12:08:56 -0700







MM/dd/yyyy HH:mm

07/04/2001 12:09



M/D/yy H:mm

1/2/09 6:17


Created in 2020 by Google Inc.