Neat date routines. Do you have a Get day of the Year function? I have one that works (I think it works), but the code is kind of ugly. Maybe there's a better way of doing this.
- Dav
- Dav
Code: (Select All)
Print "Today's date is: "; Date$
Print "Day of the year: "; DayOfTheYear
End
Function DayOfTheYear ()
'2 bytes hold num of days for each month
monthdays$ = "312831303130313130313031"
'get current date values
year = Val(Mid$(Date$, 7))
month = Val(Mid$(Date$, 1, 2))
day = Val(Mid$(Date$, 4, 2))
'tally num of days in each month
For d = 1 To month - 1 '(-1 is so we don't re-add the current month days)
day = day + Val(Mid$(monthdays$, m + 1, 2)): m = m + 2
Next
'if it's a leap year, and after february, add one more day to total
If month > 2 Then
If (year Mod 4 = 0 And year Mod 100 <> 0) Or (year Mod 400 = 0) Then
day = day + 1
End If
End If
DayOfTheYear = day
End Function