Array of hourly dates

Hello!

I’m trying to use the package Dates to create an array of dates, with the granularity of one hour. For example, I’d like to create an array with all the hours from January 10 to January 20. Any ideas on how I can do this?

Thanks in advance!

julia> using Dates

julia> d1 = DateTime("2021-01-10T12:00:00")
2021-01-10T12:00:00

julia> d2 = DateTime("2021-01-20T12:00:00")
2021-01-20T12:00:00

julia> collect(d1:Hour(1):d2)
241-element Vector{DateTime}:
 2021-01-10T12:00:00
 2021-01-10T13:00:00
 2021-01-10T14:00:00
 2021-01-10T15:00:00

see: Dates · The Julia Language

and: Dates · The Julia Language

1 Like

Thank you very much, that is exactly what I needed!

1 Like