WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Day of year and more time UDFs

 Keywords:  DayOfYear DayOfWeek LastDayOfMonth

#DefineFunction DayOfYear(ToDate)
    ThisYear=ItemExtract(1,ToDate,":")
    JanFirst="%thisyear%:01:01:00:00:00"
    JanFirstJulian=TimeJulianDay(JanFirst)
    ToJulian=TimeJulianDay(ToDate) 
    doy=ToJulian-JanFirstJulian+1
    return (doy)
#EndFunction

#DefineFunction DayOfWeek(ToDate)
    ToJulian=TimeJulianDay(ToDate) 
    dayofweekcode=(ToJulian+5) mod 7
    day=ItemExtract(dayofweekcode+1, "Sun Mon Tue Wed Thu Fri Sat", " ")
    return(day)
#endfunction

#DefineFunction LastDayOfMonth(today)
   nextmonth=TimeAdd(today,"0000:01:00:00:00:00")
   firstofnextmonth=strcat(strsub(nextmonth,1,8),"01:00:00:00")
   lastdayofthismonth=TimeSubtract(firstofnextmonth,"0000:00:01:00:00:00")
   return(lastdayofthismonth)
#endfunction

;;;enable "return" for debugging
;return


now=TimeYmdHms()
doy=DayOfYear(now)
dow=DayOfWeek(now)
Message(doy,dow)
ldm=LastDayOfMonth(now)
Message("Last day of this month",ldm)
exit


Article ID:   W14746
Filename:   Day of year and more time UDFs.txt
File Created: 2001:03:19:12:13:34
Last Updated: 2001:03:19:12:13:34