Number of days to months and days · daytomonth

🟢 2 of 2 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc3 (9e1c81a6) · pandas 2.3.3 · DuckDB 1.5.5
🟢 all ok🟡 partially implemented🛡️ refused with an error🔴 not implemented or crash🔵 engines differ ✅ match · ❌ wrong result · 🛡 guarded error (code) · 💥 crash · 📌 team decision
Dataset formsComponent formsScalar forms
        ---
config:
  flowchart:
    useMaxWidth: false

---
flowchart TB
    classDef ok fill:#d4edda,stroke:#28a745,color:#000
    classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
    classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
    classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
    classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
    classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
    classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
    O["Number of days to months and days · daytomonth 📌<br/>🟢2"]:::ok
    subgraph G_comp["Component"]
        direction LR
        v_comp["calc daytomonth(comp) 📌"]:::ok
    end
    subgraph G_sc["Scalar"]
        direction LR
        v_sc["daytomonth(sc) 📌"]:::ok
    end
    O --- G_comp
    O --- G_sc
    style G_comp fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 8 5
    style G_sc fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 2 3
    click v_comp href "#form-comp"
    click v_sc href "#form-sc"
    

Types

Takes integer · Gives duration

Comes from · integer — 20 operators in 6 blocks 🟢20
General purpose operators (2) 🟢2
String operators (2) 🟢2
Numeric operators (4) 🟢4
Time operators (7) 🟢7
Aggregate and Analytic operators (2) 🟢2
Data validation operators (3) 🟢3
Comes from · operators that return any type (their input's) — 37 operators in 8 blocks 🟢37
General purpose operators (5) 🟢5
Join operators (4) 🟢4
Time operators (3) 🟢3
Set operators (4) 🟢4
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Conditional operators (3) 🟢3
Clause operators (9) 🟢9
Goes to · duration — 6 operators in 3 blocks 🟢6
General purpose operators (1) 🟢1
Time operators (4) 🟢4
Definitions (VTL-DL) (1) 🟢1
Goes to · operators that take any scalar — 49 operators in 9 blocks 🟢49
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Clause operators (9) 🟢9
Definitions (VTL-DL) (1) 🟢1

Forms

calc daytomonth(comp) 🟢 · integer → duration

Manual example 2 🟢 pandas ✅ · DuckDB ✅
Tests:

daytomonth(Me_1) inside calc: numbers of days to months and days.

Manual:

Number days to duration, Example 2: “The operator daytomonth returns a duration having the following mask”, \PM\MDD\D, with the months and days “according to ISO 8601 M = 30D”.

Expected:

The manual’s durations, P8M0D, P24M4D and P35M6D, a String Me_2: 8 × 30, 24 × 30 + 4 and 35 × 30 + 6 days.

Erratum:

As in the page’s Example 1, of daytoyear, the manual’s output repeats Id_1 = G on its second data point, where DS_1 has H; the expected output has H.

Team decision:

#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.

script.vtl
DS_r:= DS_1[calc Me_2 := daytomonth(Me_1)];
Input DS_1
Id_1Me_1
G240
H724
T1056
Expected DS_r
Id_1Me_1Me_2
G240P8M0D
H724P24M4D
T1056P35M6D

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗

daytomonth(sc) 🟢 · integer → duration

Months of thirty days 🟢 pandas ✅ · DuckDB ✅
Tests:

daytomonth(SC_1) with SC_1 = 134, the page’s Example 3.

Manual:

Number days to duration: daytomonth (134); “returns P4M14D”; daytomonth “returns a duration having the following mask”, \PM\MDD\D, “the corresponding number of months and days; according to ISO 8601 M = 30D”.

Expected:

DS_r = P4M14D, a String: 134 = 4 × 30 + 14.

Team decision:

#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.

script.vtl
DS_r := daytomonth(SC_1);
Input scalars
SC_1
134
Expected scalars

Name

Type

Value

DS_r

String

"P4M14D"

Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗