[Tutor] datetime module problem

Kent Johnson kent37 at tds.net
Thu Apr 17 22:35:40 CEST 2008


Dick Moores wrote:
> The script calculates correctly, but note the output, lines 34, 39, 
> 49, 53. Please show me how to print these in the form 4/17/2007. I've 
> tried everything I could think of.

Come to think of it, you should be using datetime.date everywhere 
instead of datetime.datetime; you are always trying to get rid of the 
time part of datetime.

Then look at date.strftime() or datetime.strftime() to format the 
output. Use the same format string as for strptime().

Kent


More information about the Tutor mailing list