Author |
Message
|
kishoreraju |
Posted: Wed Oct 14, 2009 6:18 am Post subject: Difference between two Dates is different across in Diff Ap. |
|
|
Disciple
Joined: 30 Sep 2004 Posts: 156
|
Hi All
When i caluclated the difference between two Dates In ESQL
Code:
DECLARE NewDate DATE cast('05/27/2008' as date FORMAT 'MM/dd/yyyy');
DECLARE oldDate DATE CAST('01/01/1970' as date FORMAT 'MM/dd/yyyy');
SET inDays=(NewDate-oldDate) DAY;
SET Environment.Variables.Days=CAST(inDays AS INTEGER);
SET Environment.Variables.MilliSeconds=(((Environment.Variables.Days*24)*60)*60)*1000;
Output In MilliSeconds :1211846400000
When I do the Same in Java I am getting a differnet value
Code:
Calendar.getInstance();
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
// Set the date for both of the calendar instance
cal1.set(1970, 01, 01);
cal2.set(2008, 05, 27);
// Get the represented date in milliseconds
long milis1 = cal1.getTimeInMillis();
long milis2 = cal2.getTimeInMillis();
// Calculate difference in milliseconds
long diff = milis2 - milis1;
Output In MilliSeconds :1211842800000
In ContentIntegrator i am getting the difference between same dates the value is 1211860800000.
I am able to find out why is different in differnet application.
Thanks in advance |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Oct 14, 2009 6:24 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Are any of those the correct answer?
What is the correct answer rembering the correct number of leap years? _________________ 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 |
|
 |
Mr Butcher |
Posted: Wed Oct 14, 2009 6:42 am Post subject: |
|
|
 Padawan
Joined: 23 May 2005 Posts: 1716
|
the difference is 1 hour. so i dont think this depends on leap years. maybe just the one starting to counting from 0 and the other from 1 (just a guess) _________________ Regards, Butcher |
|
Back to top |
|
 |
kishoreraju |
Posted: Wed Oct 14, 2009 7:03 am Post subject: |
|
|
Disciple
Joined: 30 Sep 2004 Posts: 156
|
The Differnce between Java and ESQL Milliseconds is 1 Hour.
The difference between Java and ContentIntegrator is 5 Hours.
The Difference Between ESQL and ContentIntegrator is 4 Hours.
I am confusied with the above results.
I used the below URL to convert the Milliseconds into the Date format. this url is giving expected value for the ContentIntegrator milliseconds.
http://www.esqsoft.com/javascript_examples/date-to-epoch.htm
Can anyone tell what exactly going wrong with my calculation.
Thanks in Advance
Kishore. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Oct 14, 2009 7:27 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Asthe differences are an excact number of hours then I strongly suspect the the problem lies in the Time Zone and if Daylight Savings time is in effect.
My reasoning is as follows.
The UK is still on BST (Summer Time) as is the rest of Europe until the last weekend of the month.
AFAIK, The US camo out of Summertime at the end of last month.
The normal (ie for 11 months of the year) time difference between the UK and the US is 5 hours. at the moment, it is 4 hours.
At the end of the month, the UK will revert to GMT.
I'd change all your times into GMT and then do the sums.
But naturally, I could be wrong. _________________ 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 |
|
 |
|