Inconsistent results when calculating "age" of db records
От | Raheem Sarcar |
---|---|
Тема | Inconsistent results when calculating "age" of db records |
Дата | |
Msg-id | 1343283093.68099.YahooMailNeo@web163901.mail.gq1.yahoo.com обсуждение исходный текст |
Ответы |
Re: Inconsistent results when calculating "age" of db records
Re: Inconsistent results when calculating "age" of db records |
Список | 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 по дате отправления: