Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-27-2010, 08:59 AM   PM User | #1
ynotlim
Regular Coder

 
Join Date: Sep 2006
Posts: 131
Thanks: 5
Thanked 0 Times in 0 Posts
ynotlim is an unknown quantity at this point
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
ynotlim is offline   Reply With Quote
Old 08-28-2010, 10:22 AM   PM User | #2
Kakao
Regular Coder

 
Join Date: Mar 2006
Location: Brasília, Brazil
Posts: 153
Thanks: 0
Thanked 0 Times in 0 Posts
Kakao is on a distinguished road
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
Kakao is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:01 AM.


Advertisement
Log in to turn off these ads.