Skip to content

Specifying timestamp formats

The DataPrime functions parseTimestamp and formatTimestamp accept a format argument that can be used to specify the format for parsing, respectively printing a timestamp to a string. The syntax is based on the strftime function from programming languages such as Python, C or Rust. It can be any valid string with embedded format specifiers as detailed in the table below. Other parts of the string which are not format specifiers are reproduced verbatim.

SpecifierExampleMeaning
Dates
%Y2023Full year since BCE, 4 digits
%G2023Week-based full year, 4 digits
%C20Century since BCE (first 2 digits of %Y)
%y23Short year since BCE (last 2 digits %Y)
%g23Week based short year (last 2 digits of %G)
%m08Month number (01-12), zero-padded to 2 digits
%BAugustFull month name
%bAugAbbreviated month name, 3 letters
%hAugAlias for %b
%d07Day of the month (01-31), zero-padded to 2 digits
%e7Alias for %_d (space-padded)
%j219Day of the year (001-366), zero-padded to 3 digits
%u1Day of the week number, one-based (1-7), ISO 8601
%w0Day of the week number, zero-based (0-6)
%AMondayFull day of the week
%aMonAbbreviated day of the week, 3 letters
%U32Week number starting on Sunday (00-53), zero-padded to 2 digits
%W32Week number starting on Monday (00-53), zero-padded to 2 digits
%V32Week number according to ISO 8601 (01-53), zero-padded to 2 digits
%D08/07/23Alias for %m/%d/%y ("month / day / year")
%F2023-08-01Alias for %Y-%m-%d ("year - month - day"), ISO 8601
%v7-Aug-2023Alias for %e-%b-%Y ("day - month - year")
Time
%H19Hours, 24-based (00-23), zero-padded to 2 digits
%k19Alias for %_H (space-padded)
%I07Hours, 12-based (01-12), zero-padded to 2 digits
%l7Alias for %_I (space-padded)
%Ppmam or pm
%pPMAM or PM
%M06Minutes (00-59), zero-padded to 2 digits
%S42Seconds (00-60), 60 on leap seconds, zero-padded to 2 digits
%f82259081Nanoseconds since the last whole second
%3f082Milliseconds since the last whole second, zero-padded to 3 digits
%6f082259Microseconds since the last whole second, zero-padded to 6 digits
%9f082259081Nanoseconds since the last whole second, zero-padded to 9 digits
%.f.082259081Fractional part of a second (3, 6 or 9 decimals)
%.3f.082Fractional part of a second, 3 decimals (milliseconds)
%.6f.082259Fractional part of a second, 6 decimals (microseconds)
%.9f.082259081Fractional part of a second, 9 decimals (nanoseconds)
%R19:06Alias for %H:%M ("hours : minutes")
%T19:06:42Alias for %H:%M:%S ("hours : minutes : seconds")
Time Zones
%ZEurope/AthensTime zone identifier (only when parsing), IANA
%z+0300Offset from UTC in hours and minutes, zero-padded to 4 digits
%:z+03:00Offset from UTC in "hours : minutes" format
%::z+03:00:00Offset from UTC in "hours : minutes : seconds" format
%:::z+03Offset from UTC in hours, zero-padded to 2 digits
Escaping
%t\tLiteral tab character
%n\nLiteral new line character
%%%Literal percent sign
Modifiers
%-?%-I → 7Disables padding
%_?%_M → 6Pads with spaces
%0?%0e → 07Pads with zeroes

Support

Need help?

Our world-class customer success team is available 24/7 to answer any questions that may come up.

Feel free to reach out to us via our in-app chat or by sending us an email at [email protected].