Date is a calendar day. Date functions count the days, months or years between two dates and shift a date by a whole count:
Rate a policy from its dates
Save the rater asdates/rater.rsl:
Complete example: dates/rater.rsl
Complete example: dates/rater.rsl
dates/rater.rsl
YYYY-MM-DD string:
945 × 1.35 × 1.15 × 0.95 × 0.9 = 1254.38.
Declare a date input
State the earliest and latest date the input accepts:- Both ends belong to the range.
- Write
_for an open end, as in[2026-01-01, _]. - A request sends the date as a string, such as
"2026-08-15". For a Pythondate, senddate.isoformat().
Compare with a date literal
Write a date in a calculation asYYYY-MM-DD, with the quotes left out:
=, <, <=, > and >=. A policy effective on 1 July 2026 or later takes the revised premium.
A literal names a real calendar day. The check reports a literal such as 2026-06-31 with
E-DATE.
Calculate an age
diff_years(later, earlier) counts full years, as an age in years is counted:
Calculate the term and the days in force
add_months and add_years shift a date by a whole count. diff_days(later, earlier) counts the days between two dates:
premium calculation multiplies the annual premium by term_days / 365.
- Write the count as a whole number in the source, such as
6or-3. - For a count that depends on an input, write one arm for each filed count, as
expiration_datedoes. add_days(date, n)shifts by days in the same way.
Count the months between two dates
diff_months(later, earlier) counts calendar months and ignores the day of the month:
self.insured_since <= add_months(self.effective_date, -36).
Count incidents in a look-back window
A negative count shifts a date back. The window starts three years before the effective date:E-DATE-RANGE.
Read the year and the month
year(date) gives the year, and month(date) gives the month from 1 to 12:
Check month ends and leap days
A month or year shift keeps the day of the month. When the target month is shorter, the result is the last day of that month.- 31 January plus one month is 28 February, a term of 28 days.
- 29 February 2028 plus one year is 28 February 2029.
- 29 February 2028 less three years is 28 February 2025.
diff_years counts a birthday on 29 February from 1 March in a common year:
Related
- Dates in the function reference gives the form of each call.
- Rate a list of items covers
countand the other list functions. - Round a premium rounds the pro rata premium.