Author |
Message
|
Siddu |
Posted: Mon Sep 10, 2012 2:08 am Post subject: Calculating Business Days |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 44
|
Hi,
I'm trying to add a 4 business days to a current date.
I've a date in yyyy-mm-dd format.
Could you please let me know how can I calculate 4 BUSINESS DAYS?
Regards
Siddu |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 10, 2012 2:49 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Easy: if the result falls on a weekend (or holiday) add the requisite number of days. _________________ MQ & Broker admin |
|
Back to top |
|
 |
Siddu |
Posted: Mon Sep 10, 2012 3:51 am Post subject: |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 44
|
fjb_saper wrote: |
Easy: if the result falls on a weekend (or holiday) add the requisite number of days. |
How to check whether result falls on weekend?? |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Sep 10, 2012 5:00 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
Vitor |
Posted: Mon Sep 10, 2012 5:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
Code: |
int dow = cal.get(Calendar.DAY_OF_WEEK); |
|
Assuming the OP is using Java.
If not, he'll have to do the equivalant in ESQL (which is equally trivial) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Siddu |
Posted: Mon Sep 10, 2012 8:09 am Post subject: |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 44
|
Vitor wrote: |
lancelotlinc wrote: |
Code: |
int dow = cal.get(Calendar.DAY_OF_WEEK); |
|
Assuming the OP is using Java.
If not, he'll have to do the equivalant in ESQL (which is equally trivial) |
Hi All,
I did the following things in ESQL:
SET CurrentDayOfWeek=EXTRACT(DAYOFWEEK FROM CURRENT_DATE);
IF(CurrentDayOfWeek='SATURDAY') THEN
SET NumOfDaysToAdd=2;
ELSE IF(CurrentDayOfWeek='SUNDAY') THEN
SET NumOfDaysToAdd=1;
ELSE
SET NumOfDaysToAdd=0;
SET TotalNumOfBusinessDays=4+NumOfDaysToAdd;
Though I'm not clear about whether the EXTRACT(DAYOFWEEK FROM CURRENT_DATE) returns as SUNDAY or SUN.
Please correct me if I'm wrong.
Now from the definition of business days I need to consider list of holidays also along with the weekends!
Could anyone pls help me in calculating the holidays?
Your help is greatly appreciated.
Regards
Siddu |
|
Back to top |
|
 |
nathanw |
Posted: Mon Sep 10, 2012 8:12 am Post subject: |
|
|
 Knight
Joined: 14 Jul 2004 Posts: 550
|
only way i know of holidays etc as they change from country to country and years to year is to have a look up list or db entry which will need to be updated regularly
so check date against table and if holiday calculate _________________ Who is General Failure and why is he reading my hard drive?
Artificial Intelligence stands no chance against Natural Stupidity.
Only the User Trace Speaks The Truth  |
|
Back to top |
|
 |
Siddu |
Posted: Mon Sep 10, 2012 8:30 am Post subject: |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 44
|
nathanw wrote: |
only way i know of holidays etc as they change from country to country and years to year is to have a look up list or db entry which will need to be updated regularly
so check date against table and if holiday calculate |
Does anyone has a code or logic to calculate the list of holidays for any of the country?? |
|
Back to top |
|
 |
Vitor |
Posted: Mon Sep 10, 2012 8:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Siddu wrote: |
Does anyone has a code or logic to calculate the list of holidays for any of the country?? |
Most national goverments publish such things. Looking up the dates once they've been entered into a table (which can be a once a year manual process) is trivial.
Given that many holidays are arbitrary I doubt you could calculate them. For example any code to deduce UK Bank Holidays this year would have come a cropper because of the extra days for the Jubilee. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Sep 10, 2012 9:39 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
nathanw wrote: |
only way i know of holidays etc as they change from country to country and years to year is to have a look up list or db entry which will need to be updated regularly
so check date against table and if holiday calculate |
Now now Nathan, I wonder who gave you that idea then??? (only joking)
But being serious, looking out of my hotel window at the night sky in Amman, the weekend here is Friday/Sat. To the south of here in Saudi, it is Thursday/Friday. Luckily the OP may not have to cater for these little oddities. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
nathanw |
Posted: Tue Sep 11, 2012 12:25 am Post subject: |
|
|
 Knight
Joined: 14 Jul 2004 Posts: 550
|
smdavies99 wrote: |
Now now Nathan, I wonder who gave you that idea then??? (only joking)
But being serious, looking out of my hotel window at the night sky in Amman, the weekend here is Friday/Sat. To the south of here in Saudi, it is Thursday/Friday. Luckily the OP may not have to cater for these little oddities. |
Sounds familiar doesnt it  _________________ Who is General Failure and why is he reading my hard drive?
Artificial Intelligence stands no chance against Natural Stupidity.
Only the User Trace Speaks The Truth  |
|
Back to top |
|
 |
|