Shape / columns · All operations

Format a date as text

A variant of Parse a date or time

Write a date, time or timestamp out as text by a format pattern.

Status

In arcform

Runs as a SQL step

arcform carries it as a sql: step today.

The DuckDB step

Write a date out as text by a format pattern

It reads the orders table the proofs share. Create it first:

SQL
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);

Then run the statement:

SQL
CREATE TEMP TABLE result AS
SELECT order_id, strftime(order_date, '%d %B %Y') AS long_form, strftime(order_date, '%Y-%m') AS month_key FROM orders;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT [long_form, month_key] FROM result WHERE order_id = 10) = ['10 February 2026', '2026-02'] AND (SELECT long_form FROM result WHERE order_id = 1) = '03 January 2026') THEN 'as expected' ELSE error('dates were not written as 10 February 2026 and 2026-02 by their patterns') END AS verdict;
  • It needs nothing installed beyond DuckDB itself.
  • The statement checks its own result and raises an error when it is wrong: “dates were not written as 10 February 2026 and 2026-02 by their patterns”.
  • It passed on DuckDB v2.0.0 (Cyanoptera) d54cbbe3df.

What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

AWS Glue (1)
Duckle (1)
  • Format Dateread 2026-09-25

    format a date or timestamp as text

Ibis (1)
  • Strftimeread 2026-09-27

    Format a date, time or timestamp as a string by a format string

KNIME Analytics Platform (1)
RapidMiner Studio (1)
  • Date to Nominalread 2026-09-27

    Format a date column as nominal text using a date format pattern

Background

In DuckDB, strftime converts a timestamp or date to a string according to a specified pattern.[1] In DuckDB, strftime(TIMESTAMP '1992-03-02 20:32:45', '%A, %-d %B %Y - %I:%M:%S %p') writes Monday, 2 March 1992 - 08:32:45 PM.[1]

When to use it

In Python, directives such as %a, %B, %c and %x depend on the current locale, so field orderings vary and the output may contain non-ASCII characters.[2] In DuckDB, %c, %x and %X give ISO date and time representations such as 1992-03-02 10:30:20.[1] When the text is for another program rather than a person, spell the pattern out in full, year first, rather than relying on a locale's default representation. (Meridian's view)

In DuckDB format strings, the ISO week %V is incompatible with the year directive %Y, and the ISO year %G should be used with it instead.[1] In DuckDB, %U and %W number weeks from the first Sunday or Monday of the year, so a year can have a week 00, and neither follows the ISO 8601 week date standard.[1]

Python's strftime calls the platform C library's strftime function, so the full set of format codes it supports varies across platforms.[2]

The method

The format string used in strftime traces back to at least PWB/UNIX 1.0, released in 1977, whose date command included formatting options.[3]