• Post Reply Bookmark Topic Watch Topic
  • New Topic

date manipulation

 
Aanchal Tyagi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to calculate days between date field fetched from access database and current date .can any body tell me how to do it
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like this maybe:



The getTime returns milliseconds. So you calculate the difference in millis. Then we divide it by 1000 (second) * 60 (minutes) * 60 (hours) * 24 (days).

You have to take care of rounding yourself of course. In the example the result will get Floored (everything behind the comma will get ignored). You must use Math.round (and proper casting) if you want to round it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!