• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compare date cannot be greater than 12 months apart  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do do I compare one date that cannot be greater than 12 months older?
Thanks
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm probably misunderstanding what you're trying to do, but you can compare any two dates, no matter how far they are apart. Can you give us some more detail about the problem?
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, well I would parse the Date, put year, month and days into an integer each, then see if it's the same year or not. If it's the same year it's obviously not more then 12 months apart. If there is a two year difference it's obviously more then 12 months apart. If there is a one year difference you have to check how far the months are apart. And maybe if it's very close you have to check the days to.

However that is only assuming there isn't a method to compare dates anyways, which I am a bit too lazy to look up at the moment^^
[ August 14, 2007: Message edited by: Kail Limas ]
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calendar has an add() method. Would it work to create a Calendar for the earlier date, add 1 year, compare that to the later date?
 
Nazmul Bhuiyan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot to you all. Just give you more details:
In my program I'm getting a date and would like to see if the user entered date is greater then 12 months. For example user enters their date of birth and I would like to do some thing if the date of birth is greater then 12 months.
Thanks
Nazmul
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!