Skip to main content

AML Date Format

Note

Date Format applies only to fields with type: "date". Datetime fields have no data format. To format a datetime value, set the field's type to date, then use the date and time tokens below, for example dd LLL yyyy HH:mm.

Introduction​

To format your date fields, add a format property with a string pattern representing your chosen format.

Model orders {
dimension order_created_at_raw {
label: "Order Created At Raw"
type: "date"
definition: @sql {{ #SOURCE.created_at }};;
format: "dd-LL-yyyy"
}

dimension order_created_at {
label: "Order Created At"
type: "date"
definition: @sql {{ #SOURCE.created_at }};;
format: "dd LLL, yyyy"
}
}

Demostration for raw and formatted values

Syntax​

Modeling fields format​

Fields in models and datasets take format: String.

At creation, a date field shows as LLL dd yyyy (e.g., Dec 31 2020). Users can define the format once here, and every viz referencing the field inherits it by default.

dimension order_created_at {
type: "date"
format: "dd LLL, yyyy"
}

Viz fields format​

Fields inside a chart take format: FieldFormat.

By default, a viz field inherits the modeling format. Users can override the format for a specific field inside each viz.

VizFieldFull {
ref: r(orders.created_at)
format {
type: "date"
pattern: "dd LLL, yyyy"
}
}

The pattern is the same in both. Only the wrapper differs.

Pattern​

A date format pattern is a sequence of tokens and separators. If a pattern uses anything outside the supported tokens and separators, Holistics falls back to LLL dd yyyy (e.g., Dec 31 2020).

Date​

Use these tokens for the day, month, and year parts of a date.

ComponentTokenExample
Day of monthd, dd1, 01
MonthL, LL, LLL, LLLL
M, MM, MMM, MMMM
1, 01, Jan, January
Yearyy, yyyy26, 2026
Day of weekEEE, EEEEMon, Monday

M and L both represent the month (e.g., MMM and LLL display Jan), but M shows the month name in the viewer's language with embedded localization.

Time​

Use these tokens for the time part of a timestamp.

ComponentTokenExample
HourH, HH (24-hour)
h, hh (12-hour)
0–23, 00–23
1–12, 01–12
Minutem, mm0–59, 00–59
Seconds, ss0–59, 00–59
AM/PMaAM, PM

When exporting to Excel, Holistics converts these formats:

  • Minute vs. month: Excel reads m/mm as minutes only right after an hour (H, HH, h, hh) or right before a second (s, ss), like HH:mm. Anywhere else (e.g., mm/dd/yyyy), it reads a month, so Holistics exports the value as text.
  • Square brackets: Excel reads [HH]:mm as elapsed time, so Holistics exports the brackets as plain characters.

Range​

Use these tokens to show a period, such as a quarter or a week.

ComponentTokenExample
QuarterQqQ1
Week rangewwwwFeb 24 - Mar 01, 2020
Week numberW, WW1, 01

When exporting to Excel, formats that contain a range token are exported as text.

Separators​

TypeTokenDescription
Separator. / - , : and a spaceGoes between tokens
Wrap() [] {}Wraps a single token
Free text' 'Quote to add literal text, e.g., dd 'of' LLLL yyyy

Examples​

Here is how different patterns display the same raw value, 2023-12-31 14:05:09.

Format patternResult
dd/LL/yyyy31/12/2023
dd-LL-yyyy31-12-2023
LL/dd/yyyy12/31/2023
LLL dd yyyyDec 31 2023
LLL dd, yyyyDec 31, 2023
dd LLL, yyyy31 Dec, 2023
LLL yyyyDec 2023
yyyy2023
EEE, dd LLL yyyySun, 31 Dec 2023
yyyy Qq2023 Q4
'W'WW yyyyW52 2023
wwwwDec 25 - 31, 2023
HH:mm14:05
HH:mm:ss14:05:09
h:mm:ss2:05:09
h:mm a2:05 PM
[HH]:mm[14]:05
yyyy-LL-dd HH:mm:ss2023-12-31 14:05:09

Open Markdown
Let us know what you think about this document :)