Reputation: 498
I want to access the integer representation of timestamps in postgresql from javascript, it seems postgresql drivers for javascript do not support the result-column format codes in the bind message. Writing a new driver / modifying an existing one almost seems necessary. Are there any drivers which support binary result format instead of text? Or some other approach?
Tried to find a function in postgres which would allow access to the integer representation of the timestamp, and casting, but no luck.
SELECT current_timestamp::int8;
Upvotes: 0
Views: 49
Reputation: 498
Seems like this works:
CREATE CAST (timestamp AS int8) WITHOUT FUNCTION;
CREATE CAST (timestamptz AS int8) WITHOUT FUNCTION;
SELECT current_timestamp::timestamptz::int8, current_timestamp::timestamp::int8;
current_timestamp | current_timestamp |
---|---|
780063396480715 | 780063396480715 |
Upvotes: 1