Inconsistent results when calculating "age" of db records - Mailing list psycopg

From Raheem Sarcar
Subject Inconsistent results when calculating "age" of db records
Date
Msg-id 1343283093.68099.YahooMailNeo@web163901.mail.gq1.yahoo.com
Whole thread Raw
Responses Re: Inconsistent results when calculating "age" of db records  (Ghislain LEVEQUE <ghislain.leveque@clarisys.fr>)
Re: Inconsistent results when calculating "age" of db records  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
Hey All, 

I'm getting inconsistent results when looking up the age of db entries. For items that were added only minutes ago, I
getanswers like 12 or 13 hours ago.  
In my troubleshooting attempts I ran the following query directly in postgres


select age(pub_date) as days from hackerbiz_story where id=(13);


I get the following output -->
11:24:47.082  (which is correct)

Then I ran the foll query via psycopg2

cur = conn.cursor()
SQL = "select age(pub_date) as days from hackerbiz_story where id=(%s);"
cur.execute(SQL, [storyID])   //storyID is passed as argument

From which I get the following result -->
datetime.timedelta(-1, 45312, 918000).


I then apply the formula "t.seconds/3600" and get the result "12" hrs (which is incorrect).
Can someone help me to troubleshoot this further? The db is locally installed and all the code is also running locally.
I'mon the Dhaka timezone. Thanks.  

 
- Raheem M. Sarcar

psycopg by date:

Previous
From: "P. Christeas"
Date:
Subject: Re: binary protocol, again
Next
From: Ghislain LEVEQUE
Date:
Subject: Re: Inconsistent results when calculating "age" of db records