asYears
Converts a duration from seconds to years.
Parameters
DURATION (number)
The number of seconds to convert.
START DATETIME (datetime or string)
Optional. The duration is calculated forward from this date.
Input a datetime object or a string in an automatically recognized datetime pattern.
Default: 1970-01-01
END DATETIME (datetime or string)
Optional. The duration is calculated backward from this date when no start date is specified.
Input a datetime object or a string in an automatically recognized datetime pattern.
Examples
ATL in Script | Result | Notes |
---|---|---|
[[asYears(31536000)]] | 1 | 31536000 = 365 days in seconds. This converts to 1 year when counting forward from Jan 1, 1970 (default value). |
[[yrValue = asYears(31536000, '2016-01-01'); precision(yrValue, 4)]] | 0.9973 | 31536000 = 365 days in seconds. This converts to 0.9973 years when counting forward from Jan 1, 2016. Note that 2016, has 366 days. |
[[yrValue = asYears(31536000, '', '2016-01-01'); precision(yrValue, 4)]] | 1 | 31536000 = 365 days in seconds. This converts to 1 year when counting backward from Jan 1, 2016. Note that 2015 has 365 days. |
Note
The END DATETIME value is ignored when a START DATETIME is specified.