Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HDBC converting a date sql value to UTCTime

1 view
Skip to first unread message

George Moschovitis

unread,
Jun 20, 2008, 2:25:17 AM6/20/08
to
Hello,

I am HDBC with the Postgres driver. I am trying to read a simple date
column from the DB:

stmt <- DB.prepare conn "SELECT date FROM my_table ORDER BY date DESC
LIMIT 1"
DB.execute stmt []
DB.commit conn
rows <- fetchAllRows' stmt
let ((d:_):_) = rows

the d variable is of type:

SqlEpochTime 1213736400

I am wondering how to convert this value to an UTCTime value.

Any help appreciated (I am a newbie).

-g.

Matthew Danish

unread,
Jun 20, 2008, 3:08:03 PM6/20/08
to
After you pattern match SqlEpochTime and pull out the integer, what
you have here appears to be POSIX time. The time library has a module
for dealing with that: Data.Time.Clock.POSIX

The documentation is available here, among the standard library API
docs:

http://haskell.org/ghc/docs/latest/html/libraries/time/Data-Time-Clock-POSIX.html

0 new messages