DayOfYear Function?

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Is there anyway to return the day number of the year. For example, where
12/26/2003 would be = to 300.
 
If you try with 1 in a cell and then format that cell to date, then you will
get day number 1. Count the number of days from that day until the day from
which you want to start and subtract that number from int(now()).

Ole
 
Joe said:
Is there anyway to return the day number of the year. For example,
where 12/26/2003 would be = to 300.

With a simple formula, you could do something like this, assuming 12/26/2003
was in A1:

=A1-DATE(YEAR(A1),1,1)+1
 
Worksheet solution in response to your .misc query.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
If it's a programming solution you need, two possibilities could be:

Function DayOfYear(dte As Date) As Long
DayOfYear = dte - DateSerial(Year(dte), 1, 0)
' or...
DayOfYear = Format(dte, "y")
End Function

The second idea appears to be a "hair" faster, besides shorter.
 
Back
Top