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 » How To Find The Day of Week for A Given Date?

Post new topic  Reply to topic Goto page 1, 2  Next
 How To Find The Day of Week for A Given Date? « View previous topic :: View next topic » 
Author Message
Ranodip Basu
PostPosted: Sun Oct 10, 2004 9:35 pm    Post subject: How To Find The Day of Week for A Given Date? Reply with quote

Apprentice

Joined: 23 Sep 2004
Posts: 48

Hi,
I am working on WMQI 2.1. Can anybody suggest how to find the day of a given date in ESQL ? Means whether it is Monday or Tuesday or Wednesday ............
Thanks in advance.
Ranodip
Back to top
View user's profile Send private message
siliconfish
PostPosted: Sun Oct 10, 2004 9:51 pm    Post subject: Reply with quote

Master

Joined: 12 Aug 2002
Posts: 203
Location: USA

http://www.mqseries.net/phpBB2/viewtopic.php?t=7904
_________________
siliconfish
Back to top
View user's profile Send private message
kirani
PostPosted: Sun Oct 10, 2004 10:21 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

With CSD4 of WBIMB you can call a Java method with-in your ESQL code. So you can use built-in Java date functions to do this.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Ranodip Basu
PostPosted: Mon Oct 11, 2004 12:12 am    Post subject: Reply with quote

Apprentice

Joined: 23 Sep 2004
Posts: 48

Thanks both of you........I will try your suggestions and let you know............
Back to top
View user's profile Send private message
Ranodip Basu
PostPosted: Mon Oct 11, 2004 11:10 pm    Post subject: Reply with quote

Apprentice

Joined: 23 Sep 2004
Posts: 48

Hi Siliconfish,
I tried the method written in the link given by you.But it working for some cases.
For example it is working for today's date i.e 12-Oct-2004 but failing for 29-Feb-2004.If you plese can provide me some more solutions,then it will help me.
Regards,
Ranodip
Back to top
View user's profile Send private message
kirani
PostPosted: Tue Oct 12, 2004 8:39 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Have you tried the Java solution?
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Ranodip Basu
PostPosted: Fri Oct 15, 2004 3:11 am    Post subject: Reply with quote

Apprentice

Joined: 23 Sep 2004
Posts: 48

Hi Kirani,
I am extremely sorry to reply you let.I have not tried the Java solution.But what I did,I am taking a date as base - let say 10-Oct-2004(it is sunday).Now I calculating the days difference between the given date (whose days of week to be found) and the base date.
Now I am finding the mod(days difference,7)
If this mod returns 0 then it is sunday,if 1 then monday,if 2 then tuesday.........
But thanks a lot for your information.Frankly speaking I had no idea that java methods can be called within ESQL code.In future definitely it will help me............................
Ranodip
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Oct 15, 2004 5:13 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Ranodip -
I don't think you CAN call Java from ESQL in your version of WMQI. You specifically said you were using 2.1.

The support for calling Java directly from ESQL is only available in the most recent FP4 for version 5.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kirani
PostPosted: Fri Oct 15, 2004 8:39 am    Post subject: Re: How To Find The Day of Week for A Given Date? Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Ranodip Basu wrote:
I am working on WMQI 2.1.

I missed this part.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
contactop
PostPosted: Thu Nov 04, 2004 9:06 am    Post subject: Reply with quote

Acolyte

Joined: 26 Jun 2003
Posts: 50

can you tell me how to call java code from ESQL. I m using CSD04.
thanks in advance.
Back to top
View user's profile Send private message
kirani
PostPosted: Thu Nov 04, 2004 10:58 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

You can call a java method using CALL statement. For more info please look at ESQL reference manual (Page 117).
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
nathanw
PostPosted: Fri Nov 05, 2004 2:55 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

in v 5 on a projetc we used this algorithm

CREATE FUNCTION CurrentDayOfTheWeek(DateInC Char) Returns Char
BEGIN
DECLARE y Int Cast(Substring(DateInC From 9 for 2) as Int);
RETURN Case (Mod(((2 * (3 - Mod((Cast(Substring(DateInC From 7 for 2) as Int)), 4))) +
(Mod((y / 12) + mod(y,12) + (mod(y,12)/ 4), 7)) +
(Case (Cast(Substring(DateInC from 12 for 2) as Int))
when 1 then 0 when 2 then 3 when 3 then 3 when 4 then 6
when 5 then 1 when 6 then 4 when 7 then 6 when 8 then 2
when 9 then 5 when 10 then 0 when 11 then 3 when 12 then 5
End) +
(Mod((Cast(Substring(DateInC from 15 for 2) as Int)), 7))),7 ))
When 0 Then 'Sun' When 1 Then 'Mon'
When 2 Then 'Tue' When 3 Then 'Wed'
When 4 Then 'Thu' When 5 Then 'Fri'
When 6 Then 'Sat' Else'xxx'
End;
END;

looks rubbish i know but this esql works and finds the day based on the system date.

Make sure you understand it beofre going back to V 2.1

N
Back to top
View user's profile Send private message MSN Messenger
Nigelg
PostPosted: Fri Nov 05, 2004 3:28 am    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

It does indeed look rubbish.

I think it would be wonderfully improved by a few new lines and more than a few comments.
What if you leave, and it needs maintaining? How would you do it?

How DOES it work anyway?
Back to top
View user's profile Send private message
nathanw
PostPosted: Fri Nov 05, 2004 3:45 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

thx Nigel

it is based on an algorithm written by lewis carrol years ago

it takes the date and calculates the day simple as that lol

if the result of the calculation comes out to a certain value then it will alocate the day

btw this part of a much large piece of ESQL for calculation of SLAs and expiry based on business days and hours but the first thing it needs is the actual day that we are currently at.

as for maintenance well unless they are going to change th days of the week or number of days in the week then we all are going to have a problem
Back to top
View user's profile Send private message MSN Messenger
brenner
PostPosted: Mon Nov 08, 2004 11:01 pm    Post subject: Reply with quote

Newbie

Joined: 22 Oct 2004
Posts: 7
Location: IBM Hursley

Why not use the EXTRACT function instead of
DECLARE y Int Cast(Substring(DateInC From 9 for 2) as Int);
for example

DECLARE y INT EXTRACT (DAY FROM DateInC);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How To Find The Day of Week for A Given Date?
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.