GetNextDateForHolidayId

Navigation:  Appendices > Macro Language > Built-in Functions > All Functions (Alphabetical) >

GetNextDateForHolidayId

Previous pageReturn to chapter overviewNext page

int = GetNextDateForHolidayId(nHolId,nYear)

 

This macro function is used to find out the date(s) when a holiday occurs for a given year. For example, when does Easter occur in 2005 ? This function is part of a set of advanced functions that give you direct access to the holidays tables.

 

GetNextDateForHolidayId will return the next date on which a holiday of ID nHolId will occur, in the year nYear, and with the table's cursor positioned where it currently is. If a holiday is found the holidays table is moved to the next record.

 

The holiday ID used is the ID of the holidays rule, not the Holidays Set ID as was used in the function FindHolidayOnDate. You do not need to specify the Holidays Set since each holiday rule has a unique ID that determines it and the Holidays Set to which it belongs.

This function moves to the next record in the table that matches the date and Holiday ID. The result of this function depends on what happened to the holidays table beforehand. We will come back to this point below.

 

The fact that this function looks for the next holiday in the holidays table is useful to iterate through all the occurrences of the same holiday rule on the same year.

 

Most holidays occur only once a year, but there are exceptions such as Eid al F'tir (Muslim holiday), which in 2000 will occur both on January 8th and December 27th. Usually these cases will come up for religious calendars who may have years of significantly different numbers of days, (as many as 30 days in the case of the Jewish calendar).

 

As is the case for FindHolidayOnDate, you must re-initialize the table to be sure of getting all occurrences of a given holiday rule for a given year. Afterwards you call the function repeatedly, without re-initializing, to iterate through all occurrences. When there are no more occurrences the function returns 0 (zero).

 

// initialize the table

Reset_GetNextDateForHolidayId()

nYear = 1999

nHolidayId = 1878

// find an occurrence and add it to the string sRESULT

nDate = GetNextDateForHolidayId(nHolidayId,nYear)

sRESULT = sRESULT + FormatDate('c',nDate)

// look for other occurrences of same holidays, same year

while NotEqualN(nDate,0)

 sRESULT = sRESULT + FormatDate('c',nDate)

 // look again. If not found will return 0

 nDate = GetNextDateForHolidayId(nHolidayId,nYear)

endwhile

 

nHolId refers to the ID of the holidays rules you are interested in. You seldom see this ID, as you are more likely to refer to it by name, such as "New Year's Day".

 

To obtain the ID of a given holiday rule you have 2 options :

 

The ID of each holidays rule is displayed near its title in the Holidays Manager.

Sometimes you never actually see the holiday ID, you just use it. For example you may want, whenever a holidays occurs, to also list this holiday's occurrence for the next 2 years. For an example, see Getting the Date when a Holiday occurs over the Years.


Topic 105134 updated on 01-Nov-2016.
Topic URL: http://www.qppstudio.net/webhelp/index.html?getdateforholidayid.htm