Re: Difference between two dates

2008-06-24 Thread sniipe
Thank you for answers :) I used Cédric Lucantis's way to resolve this problem and it works :D -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between two dates

2008-06-24 Thread sniipe
Thank you for answers. I used Cédric Lucantis's way to resolve this problem and it works :D -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between two dates

2008-06-24 Thread A.T.Hofkamp
On 2008-06-24, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi! > > I am new in Python, so I count for your help. I need to get difference > in months between two dates. How to do it in python? I am substracting > two dates, for example date1 - date2 and I got result in days, how to > change it?

Re: Difference between two dates

2008-06-24 Thread Cédric Lucantis
Le Tuesday 24 June 2008 12:11:03 [EMAIL PROTECTED], vous avez écrit : > Hi! > > I am new in Python, so I count for your help. I need to get difference > in months between two dates. How to do it in python? I am substracting > two dates, for example date1 - date2 and I got result in days, how to > c

Difference between two dates

2008-06-24 Thread sniipe
Hi! I am new in Python, so I count for your help. I need to get difference in months between two dates. How to do it in python? I am substracting two dates, for example date1 - date2 and I got result in days, how to change it? Best regards -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between two dates in seconds

2006-09-28 Thread flupke
Duncan Booth schreef: > flupke <[EMAIL PROTECTED]> wrote: > >> Using 86400 instead of (24*60*60) is faster > > s/is/was/ > > upgrade to Python 2.5 Indeed, i'm still on 2.4. I thought 2.5 might give a different result :) Thanks for the info Benedict -- http://mail.python.org/mailman/listinfo/p

Re: Difference between two dates in seconds

2006-09-28 Thread Duncan Booth
flupke <[EMAIL PROTECTED]> wrote: > Using 86400 instead of (24*60*60) is faster s/is/was/ upgrade to Python 2.5 -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between two dates in seconds

2006-09-28 Thread flupke
Fredrik Lundh schreef: > def get_seconds(td): > ... return td.days * (24*60*60) + td.seconds > ... import dis dis.dis(get_seconds) > 2 0 LOAD_FAST0 (td) > 3 LOAD_ATTR0 (days) > 6 LOAD_CONST 4

Re: Difference between two dates in seconds

2006-09-27 Thread Fredrik Lundh
Steven D'Aprano wrote: > Arguably a better solution would be to do this: > > seconds = td.days * 24*60*60 + td.seconds if you're targeting an audience that cannot figure out what the expression does based on the names of the result and the names of the attributes, chances are that 24*60*60 won

Re: Difference between two dates in seconds

2006-09-27 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steven D'Aprano wrote: > On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote: > >> Claes at work wrote: >> >>> Please tell me there is a simpler way than subtracting two datetimes >>> to get a timedelta and then compute >>> >>> days * number of seconds per da

Re: Difference between two dates in seconds

2006-09-27 Thread Robert Kern
Steven D'Aprano wrote: > On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote: > >> Claes at work wrote: >> >>> Please tell me there is a simpler way than subtracting two datetimes >>> to get a timedelta and then compute >>> >>> days * number of seconds per day + seconds >>> >>> from it myself?

Re: Difference between two dates in seconds

2006-09-27 Thread Rob Williscroft
Steven D'Aprano wrote in news:[EMAIL PROTECTED] in comp.lang.python: > On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote: > >> Claes at work wrote: >> >>> Please tell me there is a simpler way than subtracting two datetimes >>> to get a timedelta and then compute >>> >>> days * number of

Re: Difference between two dates in seconds

2006-09-27 Thread Steven D'Aprano
On Wed, 27 Sep 2006 20:16:52 +0200, Fredrik Lundh wrote: > Claes at work wrote: > >> Please tell me there is a simpler way than subtracting two datetimes >> to get a timedelta and then compute >> >> days * number of seconds per day + seconds >> >> from it myself?? > > why would you have to do

Re: Difference between two dates in seconds

2006-09-27 Thread Claes at work
On 9/27/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Claes at work wrote: > > why would you have to do that yourself? why not let Python do it for > you? here's the code: > > seconds = td.days * 86400 + td.seconds > Thanks, but that is exactly what I meant. I had hoped there would some met

Re: Difference between two dates in seconds

2006-09-27 Thread skip
Claes> calculating the difference between two dates in seconds >>> import datetime >>> now1 = datetime.datetime.now() >>> # dum dee dum ... ... now2 = datetime.datetime.now() >>> now2-now1 datetime.timedelta(0, 12, 781540) Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between two dates in seconds

2006-09-27 Thread Fredrik Lundh
Claes at work wrote: > Please tell me there is a simpler way than subtracting two datetimes > to get a timedelta and then compute > > days * number of seconds per day + seconds > > from it myself?? why would you have to do that yourself? why not let Python do it for you? here's the code:

Difference between two dates in seconds

2006-09-27 Thread Claes at work
Hi, I am learning Python and want to perform what I think is a very simple task: calculating the difference between two dates in seconds. Reading through the documentation I am puzzled: I can't find a way to do this without doing manually what I think belongs to a standard library m