Duration to number of days: yeartoday, monthtoday
Syntax
Input parameters
yearDuration |
a duration having the following mask: PYYDDDD |
monthDuration |
a duration having the following mask: PMMDDD |
Examples of valid syntaxes
yeartoday (P1Y)
monthtoday (P3M)
ds2 := ds1[calc Me2 := yeartoday(Me1)]
Semantics for scalar operations
- The operators return an integer representing the number of days corresponding
to the given duration.
Input parameters type
op:
component<duration>
| duration
Result type
result
component<integer>
| integer
Additional Constraints
None.
Behaviour
The scalar version of the yeartoday operator takes as input a duration having the following mask: PYYDDDD; returns the corresponding number of years and days (according to ISO 8601 Y = 365D).
The scalar version of the monthtoday operator takes as input a duration having the following mask: PMMDDD; returns the corresponding number of months and days; according to ISO 8601 M = 30D).
In the component version, that can be used in a calc clause, a new component of type integer is added to the dataset.
Examples
Given the dataset DS_1:
Input DS_1 (see structure)
Id_1 |
Me_1 |
---|---|
G |
P2Y230D |
H |
P1Y23D |
T |
P3Y152D |
Example 1
DS_r:= DS_1[calc Me2 := yeartoday (Me_1)];
results in (see structure):
Id_1 |
Me_1 |
Me_2 |
---|---|---|
G |
240 |
P0Y240D |
G |
724 |
P1Y359D |
T |
1056 |
P2Y326D |
Example 2
yeartoday (P1Y20D);
returns 385.
Example 3
monthtoday (P3M10D);
returns 100.