galsaba wrote:
What would be the function to convert date to the number of date
for example, 2/14/05 is 45, becuse this is the 45th day of the year.
What would be the function?
Where can I find info on the web about it?
galsaba
The logic for rolling your own day of year would be something like:
Public Function DayOfYear(dtX As Date) As Integer
Dim PriorMonthDays As Variant
Dim boolIsLeap As Boolean
PriorMonthDays = Array(0, 31, 59, 90, 120, 151, _
181, 212, 243, 273, 304, 334)
boolIsLeap = (Year(dtX) Mod 4 = 0) - (Year(dtX) Mod 100 = 0) _
+ (Year(dtX) Mod 400 = 0)
DayOfYear = PriorMonthDays(Month(dtX) - 1) + Day(dtX) + _
boolIsLeap * (Month(dtX) > 2)
End Function
For instance, (DayOfYear(Date()) - 1) \ 7 + 1 would give the week
number based on weeks starting the day of Jan 1. Don't actually do it
this way :-). Follow the advice of the other posters. This example is
merely academic.
James A. Fortune