A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
Calculation of months between two dates
Joined: Jan 07, 2007
Feb 06, 2008 04:16:00
I have the following two date formats:
Sun Nov 04 00:00:00 IST 2007
Tue Jan 01 00:00:00 IST 2008
How to calculate the difference between these two dates in months?
Any special formatting needed using
I don't know how to use the Calendar class with the above date format.
Kindly provide your help
Joined: Feb 06, 2008
Feb 06, 2008 06:59:00
You dint mention what type of object these dates are stored in.
But anyways, I could think of this formula which would return you the number of months between two dates.
((YYYY*12)+MM) - ((YYYY*12)+MM)
Do let me know if it works.
Joined: Mar 22, 2005
Feb 06, 2008 07:08:00
That depends on how you define the number of months between two dates. In the example you provide 1, 2 and 3 are all valid answers, according to different definitions. Which one do you use?
class helps with converting dates into
and vice versa; it does not perform any date calculations.
Ping & DNS
- my free Android networking tools app
subject: Calculation of months between two dates
how do I find date difference in months
Precise age calculation..
Extracting months from Date object data
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014