ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Calculating Business Days

Post new topic  Reply to topic
 Calculating Business Days « View previous topic :: View next topic » 
Author Message
Siddu
PostPosted: Mon Sep 10, 2012 2:08 am    Post subject: Calculating Business Days Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Sep 10, 2012 2:49 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Siddu
PostPosted: Mon Sep 10, 2012 3:51 am    Post subject: Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Mon Sep 10, 2012 5:00 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Code:
 int dow = cal.get(Calendar.DAY_OF_WEEK);

_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Sep 10, 2012 5:17 am    Post subject: Reply with quote

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
View user's profile Send private message
Siddu
PostPosted: Mon Sep 10, 2012 8:09 am    Post subject: Reply with quote

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
View user's profile Send private message
nathanw
PostPosted: Mon Sep 10, 2012 8:12 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Siddu
PostPosted: Mon Sep 10, 2012 8:30 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Mon Sep 10, 2012 8:46 am    Post subject: Reply with quote

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
View user's profile Send private message
smdavies99
PostPosted: Mon Sep 10, 2012 9:39 am    Post subject: Reply with quote

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
View user's profile Send private message
nathanw
PostPosted: Tue Sep 11, 2012 12:25 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Calculating Business Days
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.