Get day of year

mlh407

Registered User.
Local time
Today, 05:28
Joined
Jun 24, 2005
Messages
26
Hi all, is there a way in access to get the day number of the year.

so 1-1-05 would be day #1 and 12-31-05 = 365

Is there a way to do this?


Michael
 
Check the Access help files for the DateDiff() function.
 
One Solution

Here is a function that will return the day of the year. You use it this way:

DayOfYear(#7/1/2005#) which returns 182


Function DayOfYear(DateToUse As Date)
'Computes the Consecutive Day for a year with Jan 1st = day 1,
' Feb 1st = day 32 etc

DayOfYear = DateDiff("d", "1/1/" & Format(DateToUse, "yyyy"), DateToUse) + 1

End Function
 
Datepart() function:

mydate = date()
? mydate
11/15/05
? datepart("y", mydate)
319

Bob
 
Michael,

You should be able to use a Date\Time Format:

Format([yourDate],"y")
 

Users who are viewing this thread

Back
Top Bottom