← daytoyear operator page · time/daytoyear/comp/manual_ex_1
pandas ✅ · DuckDB ✅
daytoyear(Me_1) inside calc: numbers of days to years and days.
Number days to duration, Example 1: "The operator daytoyear returns a duration having the following mask", \PY\YDDD\D, with the years and days "according to ISO 8601 Y = 365D".
The manual's durations, P0Y240D, P1Y359D and P2Y326D, a String Me_2: 240, 365 + 359 and 2 × 365 + 326 days.
The manual's output repeats Id_1 = G on its second data point, where DS_1 has H: the calc keeps the identifiers of DS_1, and two data points cannot share the key G. The expected output has H.
#394: a Duration holds only a period indicator (A, S, Q, M, W, D), so the ISO 8601 durations that daytoyear and daytomonth return and yeartoday and monthtoday take are Strings.
DS_r:= DS_1[calc Me_2 := daytoyear(Me_1)];
| Id_1 | Me_1 |
|---|---|
| G | 240 |
| H | 724 |
| T | 1056 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| G | 240 | P0Y240D |
| H | 724 | P1Y359D |
| T | 1056 | P2Y326D |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"},
{"name": "Me_2", "type": "String", "role": "Measure"}
]
}
]
}