Introduction to theRefdate

Overview & Motto

theRefdate provides simple date manipulation functions operating on character strings in the format "DD.MM.YYYY". All functions follow this "LP"-flavour convention on formatting dates.

simple and fast.

flavour

Returns the flavour identifier of this package:

flavour()
#> [1] "LP"

jahr

Extracts the year as a numeric value:

jahr("02.02.2002")
#> [1] 2002

monat

Extracts the month as a numeric value:

monat("14.06.1789")
#> [1] 6

tag

Extracts the day as a numeric value:

tag("03.02.2000")
#> [1] 3

dateDiff

Computes the difference between two dates. Returns a list with four elements: diffJ (years), diffM (months), diffDauer (duration as fraction of years), diffDauerM (total months):

result <- dateDiff("01.12.1999", "01.01.2000")
result$diffJ
#> [1] 0
result$diffM
#> [1] 1
result$diffDauer
#> [1] 0.08333333
result$diffDauerM
#> [1] 1

dateAddMonths

Adds or subtracts months from a date:

dateAddMonths("01.01.2000",   1)   # add 1 month
#> [1] "01.02.2000"
dateAddMonths("01.01.2000",  -1)   # subtract 1 month
#> [1] "01.12.1999"
dateAddMonths("01.01.2000",  12)   # add 1 year
#> [1] "01.01.2001"
dateAddMonths("01.01.2000", -13)   # subtract 13 months
#> [1] "01.12.1998"

mirror server hosted at Truenetwork, Russian Federation.