[postmodern-devel] timestamps return format

Timur Sufiev tsufiev at gmail.com
Mon Feb 2 10:31:41 UTC 2009


Hi!

In order to convert timestamps from unix time to GMT strings I used
the following select query:
SELECT TIMESTAMP 'epoch' + 1195374767 * INTERVAL '1 second'
or, the s-sql analogue
`(:select (:+ (:type "epoch" timestamp)
                       (:* ,unix-time (:type "1 second" interval))))
Surprisignly, it returned timestamps as numbers, not strings. After
some investigation the reason of that behaviour became clear. Consider
2 following queries.

(pomo:query (:select 'timestamp :from 'sales :where (:and (:=
'vend-machine-id 2) (:< 'timestamp "2009-01-12"))))
(("2009-01-11 18:37:18+03") ("2009-01-11 23:59:59+03") ("2009-01-11
23:59:59+03") ("2009-01-11 23:59:59+03") ("2009-01-11 23:59:59+03")
("2009-01-11 23:59:59+03"))

(pomo:query (:select (:type 'timestamp timestamp) :from 'sales :where
(:and (:= 'vend-machine-id 2) (:< 'timestamp "2009-01-12"))))
((3440687838) (3440707199) (3440707199) (3440707199) (3440707199) (3440707199))

So, type-cast to TIMESTAMP makes postmodern to return timestamps as
numbers. How is it possible to return unix-time as GMT strings via
postmodern sql queries?

-- 
Timur Sufiev




More information about the postmodern-devel mailing list