|
Previous Top Next |
Prototype: | (Long pBaseDate, Byte pWeekDay, Byte pDayIfSame=True),LONG |
pBaseDate | Base date to calculate from |
pWeekDay | The day of the week to find, IT_Sunday - IT_Saturday |
pDayIfSame | What 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. |
Returns | The 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: