Company logo

FOXSTUFF

Advice, tips, techniques and downloads for Visual Foxpro developers.

Home | Contact

Versión en español de este artículo

Generate a table of "notable dates"

Does you application need to know the date of next year's Labor Day? Or when Easter will fall in two years time? HOLIDAYS.PRG could be just what you need.

David Aherron does Visual Foxpro consulting and contracting from his base in Montpelier, VA (USA). His present application schedules phone calls to members of the public. To avoid disturbing people on holidays and certain other important dates, David has written a program which generates a table of 17 notable dates for up to two years ahead. His application checks its scheduled dates against this table to determine which ones to avoid.

David has kindly contributed his program to Foxstuff. It is called HOLIDAYS.PRG, and you can download a copy by clicking on the link at the end of this article.

Of coure, you probably won't be interested in exactly the same dates that David's program generates - Memorial Day and Columbus Day are unlikely to concern you if you are outside the USA, for example. But the program is constructed in a very modular way and should be easy to modify.

HOLIDAYS.PRG requires a table called HOLIDAY.DBF. This should have two fields:

If the program cannot find HOLIDAY.DBF, it will create it (in the default directory).

When you run the program, it will fill the table with the holiday dates for the current year and the following year. If the dates are already in the table for earlier years, these will be deleted. To check if a given date is a holiday, use LOCATE on the Holidate field to see if it is in the table. If it is, look at the corresponding Reason field to determine the name of the holiday.

Note that, because the program uses the DATE(year,month,day) function, it requires VFP 6.0 or later.

Download instructions

Click the link below to download HOLIDAYS.ZIP. This contains the PRG file and an abbreviated copy of this article. To use it, unzip it with Winzip, PKUnzip or similar. Copy the PRG to a suitable directory, and run it from within VFP. The total download size is just 4 KB.

Download now

Mike Lewis Consultants Ltd. December 1999. Updated December 2006 to take account of changes in US Daylight Saving Time.

More Visual FoxPro articles | Crystal Reports articles | Recommended books | Visual FoxPro consultancy | Contact us

FoxStuff is maintained by Mike Lewis Consultants Ltd. as a service to the VFP community. Feel free to download and use any code or components, and to pass around copies of the articles (but please do not remove our copyright notices or disclaimers).

The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications.

© Copyright Mike Lewis Consultants Ltd.