
Days in Period
dip.RdGiven any starting and ending dates, it generates:
1) a vector of class Date with all the days between from and to (both of them included), OR
2) the amount of days between the two dates
Arguments
- from
Character indicating the starting date for creating the sequence. It has to be in the format indicated by
date.fmt.- to
Character indicating the ending date for creating the sequence. It has to be in the format indicated by
date.fmt.- date.fmt
character indicating the format in which the dates are stored in
fromandto, e.g. %Y-%m-%d. Seeformatinas.Date.
ONLY required whenclass(dates)=="factor"orclass(dates)=="numeric".- out.type
Character indicating the type of result that is given by this function. Valid values are:
1) seq : a vector of class Date with all the days between the two dates, OR
2) nmbr: a single numeric value with the amount of days between the two dates.
Value
Depending on the value of out.type, it returns:
1) a vector of class Date with all the days between from and to (both of them included), OR
2) the amount of days between the two dates
Author
Mauricio Zambrano-Bigiarini, mzb.devel@gmail
Examples
## Sequence of daily dates between "1961-01-01" and "1961-12-31" ##
dip("1961-01-01", "1961-12-31")
#> [1] "1961-01-01" "1961-01-02" "1961-01-03" "1961-01-04" "1961-01-05"
#> [6] "1961-01-06" "1961-01-07" "1961-01-08" "1961-01-09" "1961-01-10"
#> [11] "1961-01-11" "1961-01-12" "1961-01-13" "1961-01-14" "1961-01-15"
#> [16] "1961-01-16" "1961-01-17" "1961-01-18" "1961-01-19" "1961-01-20"
#> [21] "1961-01-21" "1961-01-22" "1961-01-23" "1961-01-24" "1961-01-25"
#> [26] "1961-01-26" "1961-01-27" "1961-01-28" "1961-01-29" "1961-01-30"
#> [31] "1961-01-31" "1961-02-01" "1961-02-02" "1961-02-03" "1961-02-04"
#> [36] "1961-02-05" "1961-02-06" "1961-02-07" "1961-02-08" "1961-02-09"
#> [41] "1961-02-10" "1961-02-11" "1961-02-12" "1961-02-13" "1961-02-14"
#> [46] "1961-02-15" "1961-02-16" "1961-02-17" "1961-02-18" "1961-02-19"
#> [51] "1961-02-20" "1961-02-21" "1961-02-22" "1961-02-23" "1961-02-24"
#> [56] "1961-02-25" "1961-02-26" "1961-02-27" "1961-02-28" "1961-03-01"
#> [61] "1961-03-02" "1961-03-03" "1961-03-04" "1961-03-05" "1961-03-06"
#> [66] "1961-03-07" "1961-03-08" "1961-03-09" "1961-03-10" "1961-03-11"
#> [71] "1961-03-12" "1961-03-13" "1961-03-14" "1961-03-15" "1961-03-16"
#> [76] "1961-03-17" "1961-03-18" "1961-03-19" "1961-03-20" "1961-03-21"
#> [81] "1961-03-22" "1961-03-23" "1961-03-24" "1961-03-25" "1961-03-26"
#> [86] "1961-03-27" "1961-03-28" "1961-03-29" "1961-03-30" "1961-03-31"
#> [91] "1961-04-01" "1961-04-02" "1961-04-03" "1961-04-04" "1961-04-05"
#> [96] "1961-04-06" "1961-04-07" "1961-04-08" "1961-04-09" "1961-04-10"
#> [101] "1961-04-11" "1961-04-12" "1961-04-13" "1961-04-14" "1961-04-15"
#> [106] "1961-04-16" "1961-04-17" "1961-04-18" "1961-04-19" "1961-04-20"
#> [111] "1961-04-21" "1961-04-22" "1961-04-23" "1961-04-24" "1961-04-25"
#> [116] "1961-04-26" "1961-04-27" "1961-04-28" "1961-04-29" "1961-04-30"
#> [121] "1961-05-01" "1961-05-02" "1961-05-03" "1961-05-04" "1961-05-05"
#> [126] "1961-05-06" "1961-05-07" "1961-05-08" "1961-05-09" "1961-05-10"
#> [131] "1961-05-11" "1961-05-12" "1961-05-13" "1961-05-14" "1961-05-15"
#> [136] "1961-05-16" "1961-05-17" "1961-05-18" "1961-05-19" "1961-05-20"
#> [141] "1961-05-21" "1961-05-22" "1961-05-23" "1961-05-24" "1961-05-25"
#> [146] "1961-05-26" "1961-05-27" "1961-05-28" "1961-05-29" "1961-05-30"
#> [151] "1961-05-31" "1961-06-01" "1961-06-02" "1961-06-03" "1961-06-04"
#> [156] "1961-06-05" "1961-06-06" "1961-06-07" "1961-06-08" "1961-06-09"
#> [161] "1961-06-10" "1961-06-11" "1961-06-12" "1961-06-13" "1961-06-14"
#> [166] "1961-06-15" "1961-06-16" "1961-06-17" "1961-06-18" "1961-06-19"
#> [171] "1961-06-20" "1961-06-21" "1961-06-22" "1961-06-23" "1961-06-24"
#> [176] "1961-06-25" "1961-06-26" "1961-06-27" "1961-06-28" "1961-06-29"
#> [181] "1961-06-30" "1961-07-01" "1961-07-02" "1961-07-03" "1961-07-04"
#> [186] "1961-07-05" "1961-07-06" "1961-07-07" "1961-07-08" "1961-07-09"
#> [191] "1961-07-10" "1961-07-11" "1961-07-12" "1961-07-13" "1961-07-14"
#> [196] "1961-07-15" "1961-07-16" "1961-07-17" "1961-07-18" "1961-07-19"
#> [201] "1961-07-20" "1961-07-21" "1961-07-22" "1961-07-23" "1961-07-24"
#> [206] "1961-07-25" "1961-07-26" "1961-07-27" "1961-07-28" "1961-07-29"
#> [211] "1961-07-30" "1961-07-31" "1961-08-01" "1961-08-02" "1961-08-03"
#> [216] "1961-08-04" "1961-08-05" "1961-08-06" "1961-08-07" "1961-08-08"
#> [221] "1961-08-09" "1961-08-10" "1961-08-11" "1961-08-12" "1961-08-13"
#> [226] "1961-08-14" "1961-08-15" "1961-08-16" "1961-08-17" "1961-08-18"
#> [231] "1961-08-19" "1961-08-20" "1961-08-21" "1961-08-22" "1961-08-23"
#> [236] "1961-08-24" "1961-08-25" "1961-08-26" "1961-08-27" "1961-08-28"
#> [241] "1961-08-29" "1961-08-30" "1961-08-31" "1961-09-01" "1961-09-02"
#> [246] "1961-09-03" "1961-09-04" "1961-09-05" "1961-09-06" "1961-09-07"
#> [251] "1961-09-08" "1961-09-09" "1961-09-10" "1961-09-11" "1961-09-12"
#> [256] "1961-09-13" "1961-09-14" "1961-09-15" "1961-09-16" "1961-09-17"
#> [261] "1961-09-18" "1961-09-19" "1961-09-20" "1961-09-21" "1961-09-22"
#> [266] "1961-09-23" "1961-09-24" "1961-09-25" "1961-09-26" "1961-09-27"
#> [271] "1961-09-28" "1961-09-29" "1961-09-30" "1961-10-01" "1961-10-02"
#> [276] "1961-10-03" "1961-10-04" "1961-10-05" "1961-10-06" "1961-10-07"
#> [281] "1961-10-08" "1961-10-09" "1961-10-10" "1961-10-11" "1961-10-12"
#> [286] "1961-10-13" "1961-10-14" "1961-10-15" "1961-10-16" "1961-10-17"
#> [291] "1961-10-18" "1961-10-19" "1961-10-20" "1961-10-21" "1961-10-22"
#> [296] "1961-10-23" "1961-10-24" "1961-10-25" "1961-10-26" "1961-10-27"
#> [301] "1961-10-28" "1961-10-29" "1961-10-30" "1961-10-31" "1961-11-01"
#> [306] "1961-11-02" "1961-11-03" "1961-11-04" "1961-11-05" "1961-11-06"
#> [311] "1961-11-07" "1961-11-08" "1961-11-09" "1961-11-10" "1961-11-11"
#> [316] "1961-11-12" "1961-11-13" "1961-11-14" "1961-11-15" "1961-11-16"
#> [321] "1961-11-17" "1961-11-18" "1961-11-19" "1961-11-20" "1961-11-21"
#> [326] "1961-11-22" "1961-11-23" "1961-11-24" "1961-11-25" "1961-11-26"
#> [331] "1961-11-27" "1961-11-28" "1961-11-29" "1961-11-30" "1961-12-01"
#> [336] "1961-12-02" "1961-12-03" "1961-12-04" "1961-12-05" "1961-12-06"
#> [341] "1961-12-07" "1961-12-08" "1961-12-09" "1961-12-10" "1961-12-11"
#> [346] "1961-12-12" "1961-12-13" "1961-12-14" "1961-12-15" "1961-12-16"
#> [351] "1961-12-17" "1961-12-18" "1961-12-19" "1961-12-20" "1961-12-21"
#> [356] "1961-12-22" "1961-12-23" "1961-12-24" "1961-12-25" "1961-12-26"
#> [361] "1961-12-27" "1961-12-28" "1961-12-29" "1961-12-30" "1961-12-31"
## Number of days between "1961-01-01" and "1965-06-30",
## but using "%d-%m-%Y" as date format.
dip("01-01-1961", "30-06-1965", date.fmt= "%d-%m-%Y", out.type = "nmbr")
#> [1] 1642