← yeartoday operator page · time/yeartoday/comp/manual_ex_1
pandas ✅ · DuckDB ✅
yeartoday(Me_1) inside calc, on P2Y230D, P1Y23D and P3Y152D as the manual writes them, in a String Me_1 where the manual declares a Duration.
Duration to number days, Example 1: yearDuration is "a duration having the following mask", \PY\YDDD\D, and the result is "the number of days corresponding to the given duration", "according to ISO 8601 Y = 365D".
Derived from that rule: Me_2 is 960 (2 × 365 + 230), 388 (365 + 23) and 1247 (3 × 365 + 152), Integers.
The manual's output is that of Example 1 of Number days to duration, its repeated G included: its Me_1 holds numbers of days where DS_1 holds durations, and its Me_2 durations where its structure says Integer.
#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 := yeartoday (Me_1)];
| Id_1 | Me_1 |
|---|---|
| G | P2Y230D |
| H | P1Y23D |
| T | P3Y152D |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| G | P2Y230D | 960 |
| H | P1Y23D | 388 |
| T | P3Y152D | 1247 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"},
{"name": "Me_2", "type": "Integer", "role": "Measure"}
]
}
]
}