Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 553
Tomas Avatar asked Jun 13 '14 07:06

Tomas


People also ask

How do you find the date from the day of the year?

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".

How do you convert a day of the year into a date in Excel?

Write the formula in cell D2 =DATE(A2,B2,C2). Press Enter on your keyboard. The function will convert it into date.


1 Answers

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!

like image 93
user2739472 Avatar answered Oct 20 '22 02:10

user2739472