www.icetips.com  Icetips Utilities Documentation 11/14/2010    

Date Class: GetPreviousWeekDay

Previous  Top  Next  


Prototype: (Long pBaseDate, Byte pWeekDay, Byte pDayIfSame=True),LONG

 

pBaseDateBase date to calculate from
pWeekDayThe day of the week to find, IT_Sunday - IT_Saturday
pDayIfSameWhat to do if the base date is a pWeekDay, if True, then it returns the pBaseDate, if False it returns pBaseDate plus 7, i.e. same day of week next week.

 

ReturnsThe calculated weekday

 

This method is used to find the previous weekday, for example to find what day last Tuesday is calculated from the pBaseDate date.  If the pBaseDate happens to be the weekday that we are looking for then pDayIfSame determines if the method returns the pBaseDate or if it returns the pBaseDate plus 7 for last weeks date.  Day name constants are declared in the ITEquates.inc file to make day selections easy, IT_Sunday, IT_Monday, IT_Tuesday, IT_Wednesday, IT_Thursday, IT_Friday, IT_Saturday.

 

Example:

ITD  ITDateClass

D    Date

Code

D = Date(7,24,2010)  !! Saturday

ITD.ODS('Base date is:           ' & Format(D,@d18))

ITD.ODS('Next weeks Saturday is: ' & Format(ITD.GetNextWeekDay(D,IT_SaturDay,False),@d18))

ITD.ODS('Next weeks Saturday is: ' & Format(ITD.GetNextWeekDay(D,IT_SaturDay),@d18))

 

! Results:

Base date is:           July 24, 2010

Last weeks Saturday is: July 17, 2010  !! Get last week if dates match.

Last weeks Saturday is: July 24, 2010  !! Get base date if dates match.

 

 

See also:

GetPreviousWeekDay

 



Direct link to this page: http://www.icetips.com/manuals/utilities/getpreviousweekday_dateclass.htm