Jump to content

Difference Between Dates


SDyke

Recommended Posts

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

First a word of warning. You may get problems with these calculations when the timezone you are in has Daylight Saving. The calculation relies on all days having 86400000 milliseconds but some days have more or less than that at the start and end of DST.

If your Timestamps are pure dates (time is 00:00:00) then there wont be a problem as the answer will be in whole days anyway.

 

new Long (($F{d1}.getTime()-$F{d2}.getTime())/86400000)

 

That should do the trick.

If you are retrieving from an SQL database then you should be able to do this in SQL. For example in Ingres you can do

 

interval('days',date1 - date2)

 

Peter Gale

Ingres Corporation

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...