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

Iso 8601 dates 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

cast(Me_1, date) on a String measure, without a mask: the default parsing.

Manual:

Type conversion, "To date": "exactly four digits are consumed to determine the year", then a -, "exactly two digits are consumed to determine the month in the range 01-12", a - again, and "exactly two digits are consumed to determine the day of the month".

Expected:

2020-01-15 and 2021-12-31. The inputs have no blanks for the conversion to remove.

script.vtl ⇩

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

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": "String", "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": "String", "role": "Measure"},
        {"name": "Me_2", "type": "Date", "role": "Measure"}
      ]
    }
  ]
}