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 » conversion of date formats in MQSI

Post new topic  Reply to topic
 conversion of date formats in MQSI « View previous topic :: View next topic » 
Author Message
ramki
PostPosted: Mon Feb 25, 2002 7:19 am    Post subject: Reply with quote

Apprentice

Joined: 25 Sep 2001
Posts: 28

Have any one of you done a conversion of CCYYDDD (Julian date) to MMDDCCYY (Gregorian date)and vice versa in MQSI? I have not seen a function for that. All and any help will be appreciated. Thanks

Back to top
View user's profile Send private message Yahoo Messenger
meekings
PostPosted: Mon Feb 25, 2002 12:45 pm    Post subject: Reply with quote

Voyager

Joined: 28 Jun 2001
Posts: 86
Location: UK, South West

I don't think there's a straightforward way to do this. The long-winded way is to:
extract the year, determine if it's a leap year
extract the julian date
starting with a month counter at 1, progressively subtract 31, 28/29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, incrementing the counter until the julian date would go negative
now you have the day, month and year
Very klunky in ESQL but bog-standard programming.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kirani
PostPosted: Mon Feb 25, 2002 5:33 pm    Post subject: Reply with quote

Jedi Knight

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

If your database provides a date function to convert from Julian date to Gregorian date, you could call that function using PASSTHRU in ESQL. If not, write a stored function which does this conversion for you and call it in ESQL.

Regards,
Kiran
Back to top
View user's profile Send private message Visit poster's website
tchagan
PostPosted: Tue Feb 26, 2002 7:47 am    Post subject: Reply with quote

Apprentice

Joined: 10 Feb 2002
Posts: 31

I've created standard message sub-flows for this sort of thing. MQSI has no date conversion functions which has been a major complaint of mine to them since I started using the product over a year ago.

Hard coding is the only way to go in this instance, using a database is an idea but you are then building in potential failures to your message flow if the db is down.

The best idea would be for IBM to build in some formatting routines like any decent language would have.
cheers

Terry
Back to top
View user's profile Send private message
Miriam Kaestner
PostPosted: Tue Feb 26, 2002 8:18 am    Post subject: Reply with quote

Centurion

Joined: 26 Jun 2001
Posts: 103
Location: IBM IT Education Services, Germany

In WMQI 2.1, there is support for custom date/time formats in the MRM.
The Format property of DATETIME elements accepts format strings in ICU format.
Back to top
View user's profile Send private message Send e-mail
ramki
PostPosted: Wed Mar 06, 2002 12:38 pm    Post subject: Reply with quote

Apprentice

Joined: 25 Sep 2001
Posts: 28

Mathematicians and programmers have naturally interested themselves in mathematical and computational algorithms to convert between Julian day numbers and Gregorian dates. The following conversion algorithm is due to Henry F. Fliegel and Thomas C. Van Flandern:
The Julian day (jd) is computed from Gregorian day, month and year (d, m, y) as follows:


jd = ( 1461 * ( y + 4800 + ( m - 14 ) / 12 ) ) / 4 +
( 367 * ( m - 2 - 12 * ( ( m - 14 ) / 12 ) ) ) / 12 -
( 3 * ( ( y + 4900 + ( m - 14 ) / 12 ) / 100 ) ) / 4 +
d - 32075
Converting from the Julian day number to the Gregorian date is performed thus:


l = jd + 68569
n = ( 4 * l ) / 146097
l = l - ( 146097 * n + 3 ) / 4
i = ( 4000 * ( l + 1 ) ) / 1461001
l = l - ( 1461 * i ) / 4 + 31
j = ( 80 * l ) / 2447
d = l - ( 2447 * j ) / 80
l = j / 11
m = j + 2 - ( 12 * l )
y = 100 * ( n - 49 ) + i + l
Days are integer values in the range 1-31, months are integers in the range 1-12, and years are positive or negative integers. Division is to be understood as in integer arithmetic, with remainders discarded.

more info on
http://serendipity.magnet.ch/hermetic/cal_stud/jdn.htm#comp
Back to top
View user's profile Send private message Yahoo Messenger
timjohnarm
PostPosted: Mon Feb 06, 2006 1:34 pm    Post subject: Reply with quote

Apprentice

Joined: 28 Sep 2004
Posts: 40
Location: Melbourne Australia

Couln't get the formula to work. Following seems to work. Have also posted this in "noofdays - julian date" where this solution was suggested by Eddie Atherton.

CREATE FUNCTION CharToJulianDate(DD CHARACTER, MM CHARACTER, CCYY CHARACTER) RETURNS CHARACTER
BEGIN

DECLARE CCYYMMDD DATE;
DECLARE CCYY0101 DATE;
DECLARE DaysThisYear INTEGER;
DECLARE JulianResult CHARACTER;
DECLARE Pos INTEGER;

SET CCYYMMDD = CAST((CCYY || '-' || MM || '-' || DD) AS DATE);
SET CCYY0101 = CAST((CCYY || '-01-01') AS DATE);

SET DaysThisYear = CAST((CCYYMMDD - CCYY0101) DAY AS INTEGER) + 1;

SET JulianResult = '000' || CAST(DaysThisYear AS CHARACTER);
SET Pos = LENGTH(JulianResult) - 2;
SET JulianResult = CCYY || SUBSTRING(JulianResult FROM Pos FOR 3);

RETURN JulianResult;
END;
Back to top
View user's profile Send private message
EddieA
PostPosted: Mon Feb 06, 2006 1:45 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Even better. This one's 4 years old.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
TonyD
PostPosted: Mon May 22, 2006 8:45 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

I need to convert from Julian Day to Gregorian date .... tried the formula shown above but for 23 May 2006 I get 2453981 when it should be 2453879. Has anyone written ESQL to do this....or does it need Java?
Back to top
View user's profile Send private message Send e-mail
mgk
PostPosted: Tue May 23, 2006 12:46 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

The following should help, note this is V6 only, and is not tested code.

Code:
--from Julian to Gregorian
DECLARE julian CHARACTER '2006040'; --- 040th day in 2006
DECLARE julianpattern CHARACTER 'yyyyDDD';
DECLARE intermediate DATE;
DECLARE gregorianpattern CHARACTER 'MMddyyyy';
DECLARE gregorian CHARACTER;

SET intermediate = CAST(julian AS DATE FORMAT julianpattern );
SET gregorian = CAST(intermediate AS CHARACTER FORMAT gregorianpattern);

-- gregorian is now '02092006'
-- from gregorian to julian
SET intermediate = CAST(gregorian AS DATE FORMAT gregorianpattern);
SET julian = CAST(intermediate AS CHARACTER FORMAT julianpattern);

_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue May 23, 2006 3:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Looking at V6 you could also use the INTERVAL capability to determine the number of days from Jan 1st ....

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
TonyD
PostPosted: Tue May 23, 2006 12:53 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Thanks for responses....I am a bit puzzled by the reference to Julian Date as 'yyyyDDD'. The conversion I need is from a Julian day, actually day/time, in a format such as '2453879.36425' as per the following definition:

Quote:

The Julian day or Julian day number (JDN) is the number of days that have elapsed since 12 noon Greenwich Mean Time (UT or TT) on Monday, January 1, 4713 BC in the proleptic Julian calendar 1. That day is counted as Julian day zero.


The involved calculation above gets close (within 100 days) but not close enough as I need to be accurate to the minute.
Back to top
View user's profile Send private message Send e-mail
EddieA
PostPosted: Tue May 23, 2006 2:33 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Pick a date, in the recent past, wher you know the correct Julian day. Subtract the Juilan day from your input Julian Day. That will give you a DAY INTERVAL from your "known date". Use the built-in functions to add that Interval to your "known date".

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » conversion of date formats in MQSI
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.