Answered by:
Convert Day into number
Question

Answers

I don't think there is a single function to do this, but you can work it out in a Sub.
GetDay() TextWindow.WriteLine("Days from the start of the year is "+day) Sub GetDay 'Set the number of days in each month For i = 1 To 12 If (i = 2) Then If (Math.Remainder(Clock.Year,4) = 0) Then Array.SetValue("DaysInMonth",i,29) 'Leap Year Else Array.SetValue("DaysInMonth",i,28) EndIf ElseIf (i = 9 Or i = 4 Or i = 6 Or i = 11) Then Array.SetValue("DaysInMonth",i,30) Else Array.SetValue("DaysInMonth",i,31) EndIf EndFor 'Find the number of days before the start of each month Array.SetValue("DaysToStartOfMonth",1,0) For i = 2 To 12 Array.SetValue("DaysToStartOfMonth",i,Array.GetValue("DaysToStartOfMonth",i1) + Array.GetValue("DaysInMonth",i1)) EndFor 'Set day of the year day = Array.GetValue("DaysToStartOfMonth",Clock.Month)+Clock.Day EndSub
 Marked as answer by Supermethan Saturday, May 9, 2009 9:13 PM
All replies

I don't think there is a single function to do this, but you can work it out in a Sub.
GetDay() TextWindow.WriteLine("Days from the start of the year is "+day) Sub GetDay 'Set the number of days in each month For i = 1 To 12 If (i = 2) Then If (Math.Remainder(Clock.Year,4) = 0) Then Array.SetValue("DaysInMonth",i,29) 'Leap Year Else Array.SetValue("DaysInMonth",i,28) EndIf ElseIf (i = 9 Or i = 4 Or i = 6 Or i = 11) Then Array.SetValue("DaysInMonth",i,30) Else Array.SetValue("DaysInMonth",i,31) EndIf EndFor 'Find the number of days before the start of each month Array.SetValue("DaysToStartOfMonth",1,0) For i = 2 To 12 Array.SetValue("DaysToStartOfMonth",i,Array.GetValue("DaysToStartOfMonth",i1) + Array.GetValue("DaysInMonth",i1)) EndFor 'Set day of the year day = Array.GetValue("DaysToStartOfMonth",Clock.Month)+Clock.Day EndSub
 Marked as answer by Supermethan Saturday, May 9, 2009 9:13 PM

Here's another
'list of all the days in each month, april = 30, may = 31 june = 30, etc.
'note: feb. always has at least 28 days
DaysInMonth = "312831303130313130313031"DayOfTheYear = 0
'check for leap year
If (Math.Remainder(Clock.Year, 4) = 0) Then
DayOfTheYear = DayOfTheYear + 1
EndIf
'using daysinmonth add together previous months
For M = 1 To Clock.Month  1
DayOfTheYear = DayOfTheYear + Text.GetSubText(DaysInMonth, M * 2  1, 2)
EndFor
DayOfTheYear = DayOfTheYear + Clock.DayTextWindow.WriteLine(DayOfTheYear)
