← cast operator page · general/cast/date_to_string/iso_8601_dates

Iso 8601 dates 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

cast(Me_1, string) on a Date measure, without a mask: the default format.

Manual:

Type conversion: "From date: the date value is printed using the ISO-8601 representation for dates, with the year, month and day of month fields always present."

Expected:

The ISO-8601 extended form YYYY-MM-DD: 2020-01-15 and 2021-12-31.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := cast(Me_1, string)];

input/DS_1.csv ⇩

Id_1Me_1
12020-01-15
22021-12-31

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Date", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2
12020-01-152020-01-15
22021-12-312021-12-31

expected/DS_r.json ⇩

{
  "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"}
      ]
    }
  ]
}