# Thread: Date Math with weekends & holidays?

1. Member
Join Date
May 2012
Posts
7
Rep Power
0

## Date Math with weekends & holidays?

Good day,

Is there a way I can determine what date it will be in 5 days (excluding weekends and holidays)?

If not - what about just weekends? Is there a way to add custom holidays?

Thank you,

Java Code:
```		public Date getDteReturnDate() {
Calendar c = Calendar.getInstance();
c.setTime(dteRequestDate);
if (intWords < 100) {
} else {
//TODO Return Error or information screen
}
return c.getTime();
}```
Last edited by ShaneO; 07-09-2013 at 07:05 PM.

2. ## Re: Date Math with weekends & holidays?

Have you read the API documentation for the Calendar (GregorianCalendar) class? It has all the arithmetic needed for calendar calculations. except holidays; holidays differ per country (or even regions of a country) and can differ each year.

kind regards,

Jos
Last edited by JosAH; 07-09-2013 at 07:18 PM. Reason: I can't even spell ...

3. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,502
Rep Power
9

## Re: Date Math with weekends & holidays?

Originally Posted by ShaneO
Is there a way I can determine what date it will be in 5 days (excluding weekends and holidays)?
What is your actual requirement here? In 5 days the date will be 5 days later, whether the interim time has holidays or not.

Regards,
Jim

4. Just a guy
Join Date
Jun 2013
Location
Netherlands
Posts
5,114
Rep Power
9

## Re: Date Math with weekends & holidays?

He's of course talking about working days, not week days.

Me - I'd just dumbly iterate from the starting day to the ending day, checking the 'state' of each day along the way. If you have a database of 'invalid' days (holidays, weekend days, ...) you can probably make that less dumb and simply count how many days there are in total and subtract how many discount days there are between those two dates with a simple count query on the database.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•