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 Previous  1, 2
 How To Find The Day of Week for A Given Date? « View previous topic :: View next topic » 
Author Message
kirani
PostPosted: Mon Nov 08, 2004 11:22 pm    Post subject: Reply with quote

Jedi Knight

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

I guess he cannot use Extract function because he is working with CHAR STRING. EXTRACT function only works on date data types.
_________________
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: Tue Nov 09, 2004 4:56 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

beat me to it

but yes

trust me on this guys if yu put the appropriate date in it calculates the day

N
Back to top
View user's profile Send private message MSN Messenger
Nigelg
PostPosted: Wed Nov 10, 2004 6:57 am    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

Does the calculation get the day right for days in January and February of a leap year?

If this is based on the Doomsday algorithm there should be an adjustment for leap years, and I cannot see such an adjustment in the code. I rewrote this in C and it gets the days wrong before the leap day.
Here is the code. Feel free to find the bug...
Code:
 
/*
y is year number 2004
m is month number 1-12
d is day in month 1-31
*/
 /* extract century, calc 1 */
  /* RETURN (2 * (3 - Mod((Cast(Substring(DateInC From 7 for 2) as Int)), 4))) */
  y1 = y / 100;
  i1 = 2 * (3 - (y1 % 4));

  /* extract year in century, calc 2 */
  /* Mod((y / 12) + mod(y,12) + (mod(y,12)/ 4), 7) */
  y2 = (y - 1900)%100;
  i2 = ((y2/12) + y2 % 12 + ((y2%12)/4))%7;

  /* transform month */
  /* long mnums[] = {0,0,3,3,6,1,4,6,2,5,0,3,5}; */

  m1 = mnums[m];

  /* mod days */
  d1 = d%7;

  /* add it up.. */
  res = i1 + i2 + m1 + d1;

  /* final result is mod by 7 */
  res %= 7;


This works for days after the leap day in leap years, but not for before. Feb 29 is the same day as Mar 1, and all days up to Feb 29 are 1 day ahead. Here is the result of running it for this year


Quote:
$ dday 2004 3 1
Mon Mar 1 14:54:37 2004
Day is Mon
$ dday 2004 2 29
Sun Feb 29 14:54:42 2004
Day is Mon
$
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 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.