Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query Help!

Status
Not open for further replies.

Bernini

Programmer
Oct 26, 2004
98
MT
Hi

I have a table storing national holidays, and table stores :

1.Holiday Title
2.Month
3.Day

Now my web page displays the next 3 occuring holidays, this i managed to create, especially when i was in the middle of the year...but now the problem is that the remaining holiday of the year is 'New Year's Eve' and the next would be 'New Year's Day'. Now since my previous sql got only the next 3 when ordered by month and day the only display i'm getting is the 31st of december.

I would like to get...the 31st december and then restart again for the next 2...ie. 1st January and another holiday!

How can this be done?

Thanks
Ncik
 
How can this be done?
By storing the Year in the table.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your reply!

Though if i store the year i have to keep on changing and adding the year field every single year! On the other hand it seems as its the only way round!

Thanks again!
 
Actually I would tend to do this in COBOL or whatever the programming language is and then fill this table (with year), assuming you know the values are requested regularly. Each of the holidays have very set rules as to when they occur and you can come up with those and then request it for the current year.

For example.

New Years Eve and New Years Day are always December 31 and January 1.

Labor Day is the first Monday in September.

and so on.

You can look up Zeller's Congruence to figure out days given a calendar month, day and year. Like for Labor Day, you'd run this algorithm on September 1 and then adjust it the correct number of days to get the first Monday.

Probably the hardest one would be Easter or Passover, but you can find information on that one as well.

Just a hint to automate this and get the human data entry part out of it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top