• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compare date cannot be greater than 12 months apart

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do do I compare one date that cannot be greater than 12 months older?
Thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic