Thread: Day of year
View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Day of year

I'm not arguing with your solution - it is spot-on for what the OP requested.

However, it cannot be used as a 'generic' what is the julian date for a
specific date - you have to consider the year for that, because Julian date
for all dates after Feb28 in leap year differ from non-leap years. Leap year
"julian days" go to 366, all other years only go to 365.

Dave - yes, the 60th day of the year is March 1st for non-leap years, it is
Feb 29 in leap years. And in leap years, I think the "last day of the month"
for all months after that get slipped in to "next month" if you get my
meaning. Like I said, in a leap year, Dec 31 is 366 - but for any other
year, there is no 366th day.

The solution offered works - but not as a generic solution. Suppose you had
something like that up on a web site to provide people with the Julian day of
the year: Enter Month/Day. And you use the NOW() or TODAY() functions to
determine it - it's going to give different results depending on whether or
not the current year is a Leap Year or not (and whether or not the date is
on/before or after Feb 28 of that year). So to be accurate with a generic
solution, you have to consider the year also, although you can ignore
displaying the year as part of the result.


"MartinW" wrote:

Hi Dave and JLatham,

I still can't see the need for any extra

With this in a spreadsheet
=TODAY()-DATE(YEAR(TODAY()),1,0)
that you open on the 1st March 2007 your result would be 60.
If you open the same spreadsheet on 1st March 2008 your result would be 61.
Excels date system takes care of the leap year for you. It's one instance
where the volatility of the TODAY function works for you.

Regards
Martin