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 » Converting Date to Milliseconds

Post new topic  Reply to topic
 Converting Date to Milliseconds « View previous topic :: View next topic » 
Author Message
kishoreraju
PostPosted: Mon Mar 15, 2010 8:13 am    Post subject: Converting Date to Milliseconds Reply with quote

Disciple

Joined: 30 Sep 2004
Posts: 156

Hi All,

I have created a function to convert to Date into milliseconds and it is woking fine till 14 March. From 15 onwards it is giving incorrect values

The below is the function i have created

Code:
CREATE FUNCTION ConvertDateInMilliSeconds(IN PrintDate CHARACTER ) RETURNS INTEGER
BEGIN


   DECLARE CurrentZoneInMilliseconds INTEGER (ABS(CAST(LOCAL_TIMEZONE AS INTEGER)* 60) * 1000);
   DECLARE CreatedDate GMTTIMESTAMP cast((PrintDate||' 00:00:00') as GMTTIMESTAMP FORMAT 'yyyy-MM-dd HH:mm:ss');
   DECLARE EpocDate GMTTIMESTAMP CAST('1970-01-01 00:00:00' as  GMTTIMESTAMP FORMAT 'yyyy-MM-dd HH:mm:ss');
   DECLARE DiffInMilliSeconds INTEGER;
   DECLARE DateInMilliSeconds INTEGER;
   SET DiffInMilliSeconds=CAST(((CreatedDate-EpocDate) Day ) AS INTEGER);
   
   SET DateInMilliSeconds=(DiffInMilliSeconds * 24 * 60 * 60*1000)+CurrentZoneInMilliseconds;



   RETURN DateInMilliSeconds;
END;


When i pass 2010-02-01 as input ,The millisecond value given from this function is 1264996800000.

When i convert the above milliseconds into Date by using the below link
it is getting converted as Sun Jan 31 23:00:00 EST 2010 which is one hour less than actual value.

http://www.esqsoft.com/javascript_examples/date-to-epoch.htm

My understanding is daylight svaing is not applied properly. Can anytell how i can fix this.

Thanks in advance
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Mar 15, 2010 8:42 am    Post subject: Re: Converting Date to Milliseconds Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

kishoreraju wrote:
My understanding is daylight svaing is not applied properly. Can anytell how i can fix this.


Yes - stop using GMT in your function!


_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kishoreraju
PostPosted: Mon Mar 15, 2010 8:45 am    Post subject: Reply with quote

Disciple

Joined: 30 Sep 2004
Posts: 156

Thanks for quick response.

I tried with TIMESTAMP, and DATE as well but no luck.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Mar 15, 2010 8:51 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

kishoreraju wrote:
I tried with TIMESTAMP, and DATE as well but no luck.



In that case, stop using GMT on your box.


_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Mar 15, 2010 8:54 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Or, alternatively, use GMT everywhere

FWIW I've spent my morning picking bits of logs out of client machines. Half of them were put on daylight savings at the weekend, half were not but should have been and half that should have been left on GMT were changed.

(Yes. 3 halves. That's been bothering me too.)

The Trout Of Timekeeping has been wielded at a particular group of admins who apply DST by changing the base time...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Mar 15, 2010 12:00 pm    Post subject: Reply with quote

Grand High Poobah

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

with Vitor.
The time on a box should always be set in GMT.
The login parameters for the particular user then need to have the TZ information that will transform this date/time from GMT to local...

Alternatively some computers' time is set to the time zone they are physically in. However here too the principle applies. The time needs to be set correctly and not changed manually when DST is applied...

I still prefer that computer time be GMT and the users have a different TZ.... in their profile.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Mon Mar 15, 2010 12:43 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

fjb_saper wrote:

The time on a box should always be set in GMT.

This is something that an awful lot of sysadmins just don't get especially in places where GMT is actually correct for 5 months a year.

Having the system time = GMT has benefits when you are using WMQ which uses GMT by default.
_________________
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
AndreasMartens
PostPosted: Wed Mar 17, 2010 8:02 am    Post subject: LOCAL_TIMEZONE not so much Reply with quote

Acolyte

Joined: 30 Jan 2006
Posts: 65
Location: Hursley, UK

Hi,

You have unfortunately fallen foul of the problem that LOCAL_TIMEZONE is the *current* timezone offset of the broker (well, it's the timezone offset taken at the point in time in which you entered the current compute node, as per the SQL specs, but enough of that).

Hence when you go past the 14th March and your system enters DST, the LOCAL_TIMEZONE will have one extra hour, regardless of the date/time you're currently processing

cheers,
Andreas
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 » Converting Date to Milliseconds
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.