← cast operator page · general/cast/date_to_string_mask/optional_digits
pandas ✅ · DuckDB ✅
cast(Me_1, string, "{D}D/{M}M/YYYY") on a Date measure: braces around the digit of the day and of the month that may be left out.
Type Conversion and Formatting Mask: "If the numerical representation is not padded, the optional digits that can be omitted (if equal to zero) are enclosed within braces; for example {M}M means that April is represented by 4 and December by 12".
5/4/2018, 31/12/2021 and 15/1/2020: a day or a month below 10 is written with one digit, where DD and MM would pad it with a zero.
DS_r := DS_1[calc Me_2 := cast(Me_1, string, "{D}D/{M}M/YYYY")];
| Id_1 | Me_1 |
|---|---|
| 1 | 2018-04-05 |
| 2 | 2021-12-31 |
| 3 | 2020-01-15 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Date", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2018-04-05 | 5/4/2018 |
| 2 | 2021-12-31 | 31/12/2021 |
| 3 | 2020-01-15 | 15/1/2020 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Date", "role": "Measure"},
{"name": "Me_2", "type": "String", "role": "Measure"}
]
}
]
}