Reference: Timestamp Functions

CedarDB supports a variety of functions for the timestamp data type. This page currently only describes a subset of those. See SQL features for a full list of supported functions.

Functions and Operators

to_char

The to_char function formats a timestamp (with or without time zone) into a string based on a user-specified format pattern.

Syntax
to_char(timestamp Timestamp, format Text) -> Text
to_char(timestamp TimestampTZ, format Text) -> Text
Examples

Formatting the release date of CedarDB with to_char to a common U.S. datetime style:

select to_char(timestamptz 'Sep 10 2025, 5:57PM+02', 'MM/DD/YYYY HH12:MI:SS PM');
        to_char
------------------------
 09/10/2025 05:57:00 PM

Format to a common German datetime style:

select to_char(timestamptz 'Sep 10 2025, 5:57PM+02', 'DD.MM.YYYY HH24:MI:SS');
      to_char
---------------------
10.09.2025 17:57:00
Supported Format Patterns

Currently, CedarDB supports a limited but commonly used subset of PostgreSQL format patterns:

PatternDescription
AD, BCEra indicator without periods (uppercase)
ad, bcEra indicator without periods (lowercase)
A.D., B.C.Era indicator with periods (uppercase)
a.d., b.c.Era indicator with periods (lowercase)
AM / PMMeridiem indicator (before/after noon)
DAY /Day/ dayDay name (MONDAY / Monday / monday)
DY / Dy / dyAbbreviated day name (MON / Mon / mon)
IDISO day of the week (1–7, Monday=1)
DDDay of month (01–31)
MMMonth number (01–12)
MONTH / Month / monthMonth name (MARCH / March / march)
MON / Mon / monAbbreviated month name (MAR / Mar / mar)
YYYYYear (4 digits)
IYYYISO 8601 week-numbering year (4 digits)
MIMinute (00–59)
HH, HH12Hour (01–12)
HH24Hour (00–23)
SSSeconds (00–59)
SSSSSeconds past midnight (0–86399)
:, ;, ,, , ., -, /Char separators