← cast operator page · general/cast/string_to_duration/one_letter_codes
pandas ✅ · DuckDB ✅
cast(Me_1, duration) on a String measure, without a mask: the one-letter codes.
Type conversion: "To duration: If the input string starts with P, the entire string is consumed and parsed, according to the ISO-8601 standard for durations [...]. Otherwise, one of A, S, Q, M, W or D is consumed, and a duration value is returned representing the duration respectively of a year, a half of a year, a quarter of a year, a month, a week and a day."
A year, a quarter and a day, written with the same codes: A, Q and D. The inputs have no blanks for the conversion to remove.
DS_r := DS_1[calc Me_2 := cast(Me_1, duration)];
| Id_1 | Me_1 |
|---|---|
| 1 | A |
| 2 | Q |
| 3 | D |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | A | A |
| 2 | Q | Q |
| 3 | D | D |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"},
{"name": "Me_2", "type": "Duration", "role": "Measure"}
]
}
]
}