May want to consider this as well:
date= datejul(1000*year+day);
What you describe is refered to as a JULIAN date, tne number of the day in a year. Typically these look like 17023 (23rd day of year 17 which should be 2017) or 2017023. When you have the year and day separately then the DATEJUL function works as above creating a single numeric value of 2017023 from 2012 and 23.
... View more