getInDays: Convert a yyyymmdd date to a day count

View source: R/time.R

getInDaysR Documentation

Convert a yyyymmdd date to a day count

Description

Turns calendar dates written as yyyymmdd into whole days since 1970-01-01, which is the scale the engine works on. This is how you usually bring dates into a MicSim model.

Usage

getInDays(yyyymmdd)

Arguments

yyyymmdd

A vector of dates as yyyymmdd (numeric, character or factor). Alternatively, a Date vector, which is passed through.

Details

Accepts numeric, character, factor or Date input. An input that is not a real calendar date (for example 20210229, which is not a leap year) becomes NA.

Validity is checked by inversion. The date is turned into a day count and back again. When that round trip returns the original date, the date is valid.

Value

Integer vector of days since 1970-01-01, negative before it, and NA for any input that is not a real calendar date.

See Also

getInDateFormat() for the inverse.

Examples

getInDays(20200826)
getInDays(20210229)   # not a real date: NA


MicSim documentation built on Dec. 2, 2026, 1:09 a.m.