Search code examples
rdatejulian-date

Convert day of year to date


How do I convert day-of-year to date? For example, what's the date for 104th day of 2004?

This is the opposite of How do you convert POSIX date to day of year in R?


Solution

  • I found that @TMS answer ignores the year specified in the origin, replacing it with the actual year you are executing the command (as @Shekeine found). Doing this seems to work fine though:

    as.Date(104, origin = "2014-01-01")
    

    CAUTION: day-of-year is zero based in this case!