Number of days to duration: daytoyear, daytomonth
Syntax
{daytoyear | daytomonth }¹ ( op )
Input parameters
op |
an integer representing the number of days to transform |
Examples of valid syntaxes
daytoyear (422)
daytomonth (146)
ds2 := ds1[calc Me2 := daytomonth(Me1)]
Semantics for scalar operations
The operator daytoyear returns a duration having the following mask: PYYDDDD. The operator daytomonth returns a duration having the following mask: PMMDDD.
Input parameters type
op:
component<integer>
| integer
Result type
result
component<duration>
| duration
Additional Constraints
None.
Behaviour
The scalar version of the daytoyear operator takes as input an integer representing t he number of days and returns the corresponding number of years and days; according to ISO 8601 Y = 365D.
The scalar version of the daytomonth operator takes as input an integer representing the numberoof days and 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 duration is added to the dataset.
Examples
Given the dataset DS_1:
Input DS_1 (see structure)
Id_1 |
Me_1 |
---|---|
G |
240 |
H |
724 |
T |
1056 |
Example 1
DS_r:= DS_1[calc Me2 := daytoyear(Me_1)];
results in (see structure):
Id_1 |
Me_1 |
Me_2 |
---|---|---|
G |
240 |
P0Y240D |
G |
724 |
P1Y359D |
T |
1056 |
P2Y326D |
Example 2
DS_r:= DS_1[calc Me2 := daytomonth(Me_1)];
results in (see structure):
Id_1 |
Me_1 |
Me_2 |
---|---|---|
G |
240 |
P8M0D |
G |
724 |
P24M4D |
T |
1056 |
P35M6D |
Example 2
daytoyear (782);
returns P2Y52D.
Example 3
daytomonth (134);
returns P4M14D.