I'm getting inconsistent results when looking up the age of db entries. For items that were added only minutes ago, I get answers 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'm on the Dhaka timezone. Thanks.
- Raheem M. Sarcar
psycopg by date
|Next:||From: Ghislain LEVEQUE||Date: 2012-07-26 07:08:36|
|Subject: Re: Inconsistent results when calculating "age" of db records|
|Previous:||From: P. Christeas||Date: 2012-07-21 11:34:22|
|Subject: Re: binary protocol, again|