Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Mondays Tuesdays Wednesdays Thursdays Fridays Saturdays Sundays Month Year Count
Find Mondays ( whatever) In a given month Year=2008 Month=1 daycode=1 ; Sun=0 Mon=1 ... sat=6 ThisDayList="Sun Mon Tue Wed Thu Fri Sat" ThisMonthList="Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec" ThisMonth=ItemExtract(month,thismonthList," ") ThisDay=ItemExtract(daycode+1,ThisDayList," ") ; Determine if this year is a leap year Feb28="%year%:02:28:00:00:00" Feb28PlusOne=TimeAdd(Feb28,"0000:00:01:00:00:00") ;Add a day to Feb28 TestDay=ItemExtract(3,Feb28PlusOne,":") If TestDay==29 Then FebDaze=29 Else FebDaze=28 ;make small table of days on a month DaysInThisMonth=ItemExtract(Month,"31 %FebDaze% 31 30 31 30 31 31 30 31 30 31"," ") ;Get the daycode of the first of the month DaycodeOfFirst=((TimeJulianDay("%year%:%month%:01:00:00:00") +5) mod 7) ;Pause("Daycode of first of month",DayCodeOfFirst) ;Get first day of month of the desired day daycodeuse=daycode If daycodeuse < daycodeoffirst Then daycodeuse = daycodeuse+7 ;Pause("daycodeuse %daycode%",daycodeuse) DateofFirstMatchingDay = daycodeuse - DayCodeOfFirst +1 ;Pause("Get date of first matching day", DateofFirstMatchingDay) ; are there 4 or 5 of those sort of days in the month WeekDaysInMonth=4 ; always at least 4 DaysLeftAfterFirstmatchingDay = DaysInThisMonth - DateofFirstMatchingDay ;Pause("DaysLeftAfterFirstmatchingDay",DaysLeftAfterFirstmatchingDay) If DaysLeftAfterFirstmatchingDay >= 28 Then WeekDaysInMonth = WeekDaysInMonth+1 Message(ThisDay: "'s in " :ThisMonth : " " : Year, " " : WeekDaysInMonth )
Article ID: W17473
File Created: 2008:04:10:15:11:18
Last Updated: 2008:04:10:15:11:18