@@ -214,11 +214,11 @@ engine][link-tesseract]. Tesseract is currently in preview. Use the
214214
215215</WarningBox>
216216
217- Unlike the `number` type which is used for calculations on measures (e.g.,
217+ Unlike the `number` type which is used for calculations on measures (e.g.,
218218` SUM(revenue) / COUNT(*)` ), `number_agg` indicates that the `sql` parameter contains
219219a direct SQL aggregate function.
220220
221- The `sql` parameter is required and must include a custom aggregate function that returns a numeric
221+ The `sql` parameter is required and must include a custom aggregate function that returns a numeric
222222value.
223223
224224<CodeTabs>
@@ -646,8 +646,8 @@ cubes:
646646
647647</CodeTabs>
648648
649- Note that the type of the target column should be ` TIMESTAMP`.
650- If your time-based column is type `DATE` or another temporal type,
649+ Note that the type of the target column should be ` TIMESTAMP`.
650+ If your time-based column is type `DATE` or another temporal type,
651651you should cast it to a timestamp in the `sql` parameter of the dimension.
652652
653653<ReferenceBox>
@@ -998,8 +998,103 @@ cubes:
998998
999999</CodeTabs>
10001000
1001+ ### Custom time formatting
1002+
1003+ Dimensions with ` time` type support custom formatting using
1004+ [POSIX strftime][link-strftime] format strings with [d3-time-format][link-d3-time-format] extensions.
1005+
1006+ <WarningBox>
1007+
1008+ Custom time formatting is currently applied only in Cube Cloud and the MDX API.
1009+ For other integrations, such as embedded analytics, you will need to apply the
1010+ formatting on the client side using the format specification from the metadata.
1011+
1012+ </WarningBox>
1013+
1014+ <CodeTabs>
1015+
1016+ ` ` ` javascript
1017+ cube(` orders`, {
1018+ // ...
1019+
1020+ dimensions : {
1021+ created_at : {
1022+ sql : ` created_at` ,
1023+ type : ` time` ,
1024+ format : ` %Y-%m-%d %H:%M:%S`
1025+ }
1026+ }
1027+ })
1028+ ```
1029+
1030+ ``` yaml
1031+ cubes :
1032+ - name : orders
1033+ # ...
1034+
1035+ dimensions :
1036+ - name : created_at
1037+ sql : created_at
1038+ type : time
1039+ format : " %Y-%m-%d %H:%M:%S"
1040+ ` ` `
1041+
1042+ </CodeTabs>
1043+
1044+ #### Common format examples
1045+
1046+ | Format string | Example output |
1047+ |---------------|----------------|
1048+ | ` %m/%d/%Y %H:%M` | 12/04/2025 14:30 |
1049+ | `%Y-%m-%d %H:%M:%S` | 2025-12-04 14:30:00 |
1050+ | `%B %d, %Y` | December 04, 2025 |
1051+ | `%b %d, %Y` | Dec 04, 2025 |
1052+ | `%I:%M %p` | 02:30 PM |
1053+ | `%A, %B %d` | Thursday, December 04 |
1054+ | `Q%q %Y` | Q4 2025 |
1055+ | `Week %V, %Y` | Week 49, 2025 |
1056+
1057+ # ### Supported format specifiers
1058+
1059+ | Specifier | Description |
1060+ |-----------|-------------|
1061+ | `%a` | Abbreviated weekday name |
1062+ | `%A` | Full weekday name |
1063+ | `%b` | Abbreviated month name |
1064+ | `%B` | Full month name |
1065+ | `%c` | Locale's date and time |
1066+ | `%d` | Day of month [01,31] |
1067+ | `%e` | Space-padded day of month |
1068+ | `%f` | Microseconds |
1069+ | `%g` | ISO 8601 year without century |
1070+ | `%G` | ISO 8601 year with century |
1071+ | `%H` | Hour (24-hour) [00,23] |
1072+ | `%I` | Hour (12-hour) [01,12] |
1073+ | `%j` | Day of year [001,366] |
1074+ | `%L` | Milliseconds |
1075+ | `%m` | Month [01,12] |
1076+ | `%M` | Minute [00,59] |
1077+ | `%p` | AM or PM |
1078+ | `%q` | Quarter [1,4] |
1079+ | `%Q` | Milliseconds since UNIX epoch |
1080+ | `%s` | Seconds since UNIX epoch |
1081+ | `%S` | Second [00,61] |
1082+ | `%u` | Monday-based weekday [1,7] |
1083+ | `%U` | Sunday-based week number [00,53] |
1084+ | `%V` | ISO 8601 week number |
1085+ | `%w` | Sunday-based weekday [0,6] |
1086+ | `%W` | Monday-based week number [00,53] |
1087+ | `%x` | Locale's date |
1088+ | `%X` | Locale's time |
1089+ | `%y` | Year without century [00,99] |
1090+ | `%Y` | Year with century |
1091+ | `%Z` | Time zone name |
1092+ | `%%` | Literal percent sign |
1093+
10011094[ref-string-time-dims] : /product/data-modeling/recipes/string-time-dimensions
10021095[ref-schema-ref-preaggs-rollup] :
10031096 /product/data-modeling/reference/pre-aggregations#rollup
10041097[ref-calculated-measures] : /product/data-modeling/concepts/calculated-members#calculated-measures
10051098[ref-drilldowns] : /product/apis-integrations/recipes/drilldowns
1099+ [link-strftime] : https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html
1100+ [link-d3-time-format] : https://d3js.org/d3-time-format
0 commit comments