Checking for valid date input and convert appropriately

Ferrous Cranus nikos.gr33k at gmail.com
Thu Feb 21 19:12:40 EST 2013


Please i have been trying hours for this:
	
try:
		datetime.strptime(date, '%d m% %Y')
		date = date.strftime('%Y-%m-%d')
	except:
		print( "<h2>date not propetly entered." )
		sys.exit(0)
===========================

the user enters 21 02 2013

a) i just need to check if its in accepted format
b) then truncate the given date to mysql format

That's all i want to do and i cant make it work. Plese tell me how to write this.

I have tried anything i can think of.



More information about the Python-list mailing list