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

Iso 8601 intervals 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

cast(Me_1, time) on a String measure, without a mask: ISO-8601 intervals.

Manual:

Type conversion: "To time: the input string is parsed, according to the ISO-8601 standard for time intervals, up to a precision of days, and the corresponding time value is returned."

Expected:

2020-01-01/2020-06-30 and 2021-03-15/2021-03-20, a time written start/end, as vtlengine reads it. The inputs have no blanks for the conversion to remove.

script.vtl ⇩

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

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