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

Date Class: GetNextWeekDay

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 next weekday, for example to find what day next 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 next 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

Next weeks Saturday is: July 31, 2010  !! Get next week if dates match.

Next 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/getnextweekday_dateclass.htm