Skip to main content
Converts a value of type DATE, TIMESTAMP, or TIMESTAMPTZ to a formatted string.

Syntax

Parameters

Accepted <format> patterns include: Additionally, modifiers can be applied to the format patterns above to alter their behavior. Any character in the format string that is not recognized as a pattern is simply copied over without being replaced. Parts that are quoted " will be copied over independent of possibly valid patterns. Patterns are matched in lower and upper case if there is no other behavior described above.

Return Types

Formatted string based on the function’s specifications

Examples

The example below outputs the current local time in a formatted string. Note that the " around the words Date and Time are required, otherwise the characters D and I would be interpreted as valid patterns which would result in the output 6ate and T3me.

Rows: 1Execution time: 5.95ms

The following example outputs the current date in a formatted string with any time field set to 0 which indicates midnight. Note the quotation marks again that are required to prevent unintended replacements:

Rows: 1Execution time: 5.81ms