Skip to contents

Generate a sequence of dates

Usage

seq_dates(start_date, end_date, by = "1h")

Arguments

start_date

Start date as YYYYMMDD, YYYYMMDDhh, or YYYYMMDDhhmm. Can be string or numeric.

end_date

End date as YYYYMMDD, YYYYMMDDhh, or YYYYMMDDhhmm. Can be string or numeric.

by

Increment of the sequence. Should be a string of a number followed by a letter, where the letter gives the units - may be d for days, h for hours or m for minutes. The default is '1h'.

Value

A sequence of date-times in YYYYMMDDhhmm format

Examples

seq_dates(20170101, 20170131, by = "1d")
#>  [1] "201701010000" "201701020000" "201701030000" "201701040000" "201701050000"
#>  [6] "201701060000" "201701070000" "201701080000" "201701090000" "201701100000"
#> [11] "201701110000" "201701120000" "201701130000" "201701140000" "201701150000"
#> [16] "201701160000" "201701170000" "201701180000" "201701190000" "201701200000"
#> [21] "201701210000" "201701220000" "201701230000" "201701240000" "201701250000"
#> [26] "201701260000" "201701270000" "201701280000" "201701290000" "201701300000"
#> [31] "201701310000"
seq_dates(201701010600, 201701051200)
#>   [1] "201701010600" "201701010700" "201701010800" "201701010900" "201701011000"
#>   [6] "201701011100" "201701011200" "201701011300" "201701011400" "201701011500"
#>  [11] "201701011600" "201701011700" "201701011800" "201701011900" "201701012000"
#>  [16] "201701012100" "201701012200" "201701012300" "201701020000" "201701020100"
#>  [21] "201701020200" "201701020300" "201701020400" "201701020500" "201701020600"
#>  [26] "201701020700" "201701020800" "201701020900" "201701021000" "201701021100"
#>  [31] "201701021200" "201701021300" "201701021400" "201701021500" "201701021600"
#>  [36] "201701021700" "201701021800" "201701021900" "201701022000" "201701022100"
#>  [41] "201701022200" "201701022300" "201701030000" "201701030100" "201701030200"
#>  [46] "201701030300" "201701030400" "201701030500" "201701030600" "201701030700"
#>  [51] "201701030800" "201701030900" "201701031000" "201701031100" "201701031200"
#>  [56] "201701031300" "201701031400" "201701031500" "201701031600" "201701031700"
#>  [61] "201701031800" "201701031900" "201701032000" "201701032100" "201701032200"
#>  [66] "201701032300" "201701040000" "201701040100" "201701040200" "201701040300"
#>  [71] "201701040400" "201701040500" "201701040600" "201701040700" "201701040800"
#>  [76] "201701040900" "201701041000" "201701041100" "201701041200" "201701041300"
#>  [81] "201701041400" "201701041500" "201701041600" "201701041700" "201701041800"
#>  [86] "201701041900" "201701042000" "201701042100" "201701042200" "201701042300"
#>  [91] "201701050000" "201701050100" "201701050200" "201701050300" "201701050400"
#>  [96] "201701050500" "201701050600" "201701050700" "201701050800" "201701050900"
#> [101] "201701051000" "201701051100" "201701051200"