Re: working days between two calendar days
From: Steven Burn (somewhere_at_in-time.invalid)
Date: 03/09/05
- Next message: Morten: "Re: Re: LsaAddAccountRights"
- Previous message: Nic Roche: "Re: .ini file to read script values"
- In reply to: Bill James: "Re: working days between two calendar days"
- Next in thread: Dr John Stockton: "Re: working days between two calendar days"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Mar 2005 13:01:00 -0000
hehe, you mean Dr Stockton wasn't being pedantic? <g>
-- Regards Steven Burn Ur I.T. Mate Group www.it-mate.co.uk Keeping it FREE! "Bill James" <wgjames@mvps.org> wrote in message news:OB4XF0GJFHA.1948@TK2MSFTNGP14.phx.gbl... I think you missed the point - the sample was never intended to be a general one size fits all script, merely responding to a post about calculating holidays. Sure, it can be improved, most code can be, and it could be streamlined but we are talking about saving milliseconds of execution for this type of script. Regarding MLK day, President's Day, Columbus Day, Veteran's Day, those are generally not business holidays in the U.S. except for banking, government and education, and are not day's off at the company I work for, but it would be a minor task to add them if needed for a specific requirement. -- Bill James Microsoft MVP - Shell/User Windows VBScript Utilities » www.billsway.com/vbspage/ Windows Tweaks & Tips » www.billsway.com/notes_public/ "Dr John Stockton" <spam@merlyn.demon.co.uk> wrote in message news:FKcdeBC1VjLCFw6W@merlyn.demon.co.uk... > JRS: In article <unQarJ6IFHA.3196@TK2MSFTNGP15.phx.gbl>, dated Mon, 7 > Mar 2005 22:48:08, seen in news:microsoft.public.scripting.vbscript, > Bill James <wgjames@mvps.org> posted : >>I'm using this functions on several scripts and VB apps. Once a person sees how >>the holidays are calculated, it's not too tough to add others. Well, not too >>tough unless you want holidays like Good Friday which are not based on the >>Gregorian calendar. > > And who do you think it was that decreed the present rules for Easter > Sunday? I know what you have in mind, but that is hardly the way to say > it. And note that the secular Gregorian Calendar determines March 21st, > which occurs at intervals of 365 or 366 days, and is fundamental to > determining the Paschal Full Moon, and hence Easter Sunday. > <URL:http://www.merlyn.demon.co.uk/holydays.htm> > > Please set your text right margin to about 72 characters, for ease of > reading. > > > >> Case 5 >> 'Memorial Day - last Mon >> If iWeekDay = 2 Then >> 'walk backward from May 31st to find last Mon >> For iCnt = 0 To 6 >> tmpDate = DateAdd("d", -iCnt, CDate("5/31/" & Year(dDate))) >> If tmpDate = CDate(dDate) Then >> IsHoliday = True >> sHoliday = "Memorial Day" >> Exit For >> End If >> Next >> End If > > Very crude. The day-of-month of the last Monday in May is easily > determined from the day-of-week of the 31st; it is 0..6 days earlier. > > Using CDate("M/D/Y") may well be unreliable; even in North America, some > prefer D/M/Y. DateSerial(Y, M, D) should be reliable everywhere and > probably faster. > > This gets the last Monday in May directly : > > tmpDate = DateSerial(Y, 5, 31) > tmpDate = tmpDate - (tmpDate+5) mod 7 > ' 5 chosen (empirically) for Monday > > > >> 'walk forward from Sep 1st to find first Mon > > As for Last Mon in May, reversed. > > >> sHoliday = "Christmas" >> 'Christmas falls on Sat, Fri is holiday > > Not, AIUI, always; not even in Canada. > > > The code could be reduced and simplified by using a generic N'th X-day > of month M routine; note that the last X-day of M is the zeroth X-day of > M+1. > > <URL:http://www.merlyn.demon.co.uk/vb-dates.htm> > > BTW, you seem not to have included MLK day, President's Day, Columbus > Day, Veteran's Day; but perhaps those are not general holidays in the > US? Then there's the Friday after Thanksgiving ... > > Is <URL:http://www.merlyn.demon.co.uk/holidays.htm#NA> OK ? > > > -- > © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. © > Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms > PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm > Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
- Next message: Morten: "Re: Re: LsaAddAccountRights"
- Previous message: Nic Roche: "Re: .ini file to read script values"
- In reply to: Bill James: "Re: working days between two calendar days"
- Next in thread: Dr John Stockton: "Re: working days between two calendar days"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|