knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(actuary)

Reference dates functions

Purpose

Business reports are prepared once a month, once a quarter or once a year. Analysts often compare business results against previous periods. First and last days of a given period are of special significance for reporting.

The dref_ prefix stands for date reference functions. The functions with the dref_ prefix return a reference date to the chosen date.

Functions

The functions work within three types of periods:

The functions return one of the four type of reference dates:

The names of functions combine the dref_ prefix and the first letters of the chosen reference date.

For example, dref_fdoy() returns the first day of year.

The table summarizes all reference date functions.

| | of month | of quarter | of year | |-------------------|----------------|----------------|----------------| | first day | dref_fdom() | dref_fdoq() | dref_fdoy() | | first working day | dref_fwdom() | dref_fwdoq() | dref_fwdoy() | | last day | dref_ldom() | dref_ldoq() | dref_ldoy() | | last working day | dref_lwdom() | dref_lwdoq() | dref_lwdoy() |

All functions take the argument date, which is the base date. The functions return the result in reference to the base date. The functions always work within a specific period: a month, a quarter or an year.

Monthly periods

The reference dates in the image below can be retrieved with the following functions:

The base date has been marked with orange.

knitr::include_graphics("img/dref_monthly.png")

Quarterly periods

The reference dates in the image below can be retrieved with the following functions:

The base date has been marked with orange.

Watch out! The first day of a year is the same as the first working day of a year. The last day of a year is the same as the last working day of a year. Hence, the same day is marked with two colors (darker and lighter).

knitr::include_graphics("img/dref_quarterly.png")

Yearly periods

The reference dates in the image below can be retrieved with the following functions:

The base date has been marked with orange.

Watch out! The first day of a year is the same as the first working day of a year. The last day of a year is the same as the last working day of a year. Hence, the same day is marked with two colors (darker and lighter).

knitr::include_graphics("img/dref_yearly.png")


zchmielewska/actuary documentation built on Feb. 5, 2020, 6:43 p.m.