[Tutor] datetime module problem

Dick Moores rdm at rcblue.com
Thu Apr 17 22:20:32 CEST 2008


At 06:29 AM 4/17/2008, Kent Johnson wrote:
>Dick Moores wrote:
>
>>>You could either create n with hours=minutes=0, or round the 
>>>difference up to the next whole number of days.
>>I have no idea how to implement either of your suggestions as to 
>>how to eliminate it. Could you please spell them both out?
>
>1.
>
>In [17]: n=datetime.today()
>In [18]: n=datetime(n.year, n.month, n.day)
>In [19]: n
>Out[19]: datetime.datetime(2008, 4, 17, 0, 0)
>
>2.
>
>In [20]: diff=y-n
>In [21]: diff
>Out[21]: datetime.timedelta(0, 57464, 721369)
>In [22]: days = diff.days
>In [23]: if diff.seconds or diff.microseconds:
>    ....:     days += 1
>    ....:
>    ....:
>In [24]: days
>Out[24]: 1

Thanks, Kent. So here's where I am now: 
<http://py77.python.pastebin.com/f5da44111>

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.

Dick



            ================================
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/ 



More information about the Tutor mailing list