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?
To get a real date from day number, or "nth day of year" you can use the DATE function. The DATE function build dates from separate year, month, and day values. One of it's tricks is the ability to roll forward to correct dates when given days and months that are "out of range".
Write the formula in cell D2 =DATE(A2,B2,C2). Press Enter on your keyboard. The function will convert it into date.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With