Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    131
    Thanks
    5
    Thanked 0 Times in 0 Posts

    compare string date to see if older

    Hi,

    I have two strings with dates and want to compare to see if it's older or not.

    date1 = "2010-08-08 21:20:47"
    date2 = "2010-07-08 21:20:47"

    if(date1 > date2):
    older = True

    How can i check to see if date1 is older than date2?

    Thanks!
    ---------
    Client / Server Side Programmer II

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Location
    Brasília, Brazil
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If the strings are well formed then just compare as you did but the opposite (the smaller is older):
    Code:
    if(date1 < date2):
       older = True # date1 is older


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •