• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Comparing two dates

 
M Burke
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the best way to compare two dates? If you have two dates with a year, month and day, and you want to return "true" if date #1 is less than or == to Date #2.
 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find the answer in the Java API documentation for java.util.Date class.
[ February 14, 2005: Message edited by: Yosi Hendarsjah ]
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have them as individual integer values (3 each), you can skip creating a Date from them and just do it in an if test. You should reason out what that would look like, but I'll get you started.
  • Any date in 2004 is before every date in 2005.
  • In the same year, earlier months come before later months regardless of day of month.
  • ... (I gotta leave something for you to figure out!)

  •  
    Senthil B Kumar
    Ranch Hand
    Posts: 160
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    [ February 21, 2005: Message edited by: kolkata prince ]
     
    David Harkness
    Ranch Hand
    Posts: 1646
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    CODE tags! CODE tags! CODE tags!

    Check out the "Instant UBB Code" buttons below the "Add Reply" button.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic