The function converts a date (day, month, year) to Calendar Day (day of year).

day_of_year(day, format = "%Y-%m-%d")

Arguments

day

character numerical date in standard format (e.g. "2017-01-02", "01-02", "01/02/2017" etc).

format

character date format following as.POSIXlt conventions. Default value = "%Y-%m-%d".

Value

numeric Julian day number, 1-366 (e.g. 1 for January 1st).

Examples

  day_of_year(day    = "2017-04-22", 
              format = "%Y-%m-%d")
#> [1] 112
  day_of_year(day    = "2017-04-22")
#> [1] 112
  day_of_year(day    = "04/22/2017", 
              format = "%m/%d/%Y")
#> [1] 112