← cast operator page · general/cast/time_to_string/iso_8601_intervals

Iso 8601 intervals 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

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

Manual:

Type conversion: "From time: the time value is printed using the ISO-8601 representation for generic time intervals, up to a maximum of day precision, in the form start/end."

Expected:

2020-01-01/2020-06-30 and 2021-03-15/2021-03-20, with the dates in the ISO-8601 extended form YYYY-MM-DD.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1
12020-01-01/2020-06-30
22021-03-15/2021-03-20

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2
12020-01-01/2020-06-302020-01-01/2020-06-30
22021-03-15/2021-03-202021-03-15/2021-03-20

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "Time", "role": "Measure"},
        {"name": "Me_2", "type": "String", "role": "Measure"}
      ]
    }
  ]
}