<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Le 17/12/11 11:19, nukeymusic a écrit :
    <blockquote
cite="mid:36f818ba-b0b0-413f-a3e9-1485a2acb238@u6g2000vbg.googlegroups.com"
      type="cite">
      <pre wrap="">I'm trying to calculate the difference in seconds between two
timestamps, but I'm totally stuck:
date1="Dec-13-09:47:12"
date2="Dec-13-09:47:39"
</pre>
      <blockquote type="cite">
        <blockquote type="cite">
          <blockquote type="cite">
            <pre wrap="">diff=datetime.date(date2)-datetime.date(date1)
</pre>
          </blockquote>
        </blockquote>
      </blockquote>
      <pre wrap="">Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required

struct_date1=time.strptime(date1, "%b-%d-%H:%M:%S")
struct_date2=time.strptime(date2, "%b-%d-%H:%M:%S")
</pre>
      <blockquote type="cite">
        <blockquote type="cite">
          <blockquote type="cite">
            <pre wrap="">diff=datetime.date(struct_date2)-datetime.date(struct_date1)
</pre>
          </blockquote>
        </blockquote>
      </blockquote>
      <pre wrap="">Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required

thanks in advance
nukey
</pre>
    </blockquote>
    That's work:<br>
    <br>
    <br>
    import datetime<br>
     <br>
    begin = datetime.datetime(2011, 12, 13, 9, 47, 12)<br>
    today = datetime.datetime(2011, 12, 13, 9, 47, 39)<br>
    dif = str(today - begin)<br>
    print dif<br>
    <br>
    >>> 0:00:27<br>
    <br>
    Regards<br>
    <br>
    <br>
    <br>
    <div class="moz-signature">-- <br>
      Vincent V.V.<br>
      <a href="https://launchpad.net/oqapy">Oqapy</a> . <a
        href="https://launchpad.net/qarte+7">Qarte+7</a> . <a
        href="https://launchpad.net/paqager">PaQager</a></div>
  </body>
</html>