Database Administrators Asked by ovatsug25 on October 28, 2021
I’m trying to create a few functions to make the SQL queries between my SQLite and Postgres DB’s the same.
One thing I would like to do is change a timestamp to a double via a function such as:
create function tz_to_double(a timestamp) returns DOUBLE PRECISION as $$
SELECT EXTRACT(EPOCH FROM TIMESTAMP a);
$$ language sql;
Postgres however doesn’t allow me to create this function. It errors out like so:
ERROR: syntax error at or near "a"
LINE 2: SELECT EXTRACT(EPOCH FROM TIMESTAMP a);
Would it be possible to create this function / use this as a param?
You are adding both Timestamp
and a
in extract function, just remove TIMESTAMP
create function tz_to_double(a timestamp) returns DOUBLE PRECISION as $$
SELECT EXTRACT(EPOCH FROM a);
$$ language sql;
Answered by Thirumal on October 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP