How to convert a timestamp (DATE FORMAT) to BIGINT in SQL
sql
Solution
For Postgres you can use:
INSERT INTO table1 (BINGINT_DATE, TIMESTAMP_DATE)
VALUES (to_char(current_timestamp, 'yyyymmddhh24miss')::bigint, CURRENT_TIMESTAMP);
Problem
I need to convert the timestamp value (Format: `2012-11-19 14:29:50.0`) to a `BIGINT` value (Format: `2012111315041650` = `YYYYMMDDhhmmss`). I need to insert current time in a column of a table which accepts only `BIGINT`. I am using Squirrel SQL Client Version 3.3.0. The query I am using right now is ``` INSERT INTO table1 (BINGINT_DATE, TIMESTAMP_DATE) VALUES (2012111315041650, CURRENT_TIMESTAMP); ``` Instead of manually entering the `BIGINT_DATE` value, I want to convert the `CURRENT_TIMESTAMP` or `NOW()` to a `BIGINT` value as the format `YYYYMMDDHHMISS` Something like ``` INSERT INTO table1 (BINGINT_DATE, TIMESTAMP_DATE) VALUES ("CONVERT(CURRENT_TIMESTAMP,BIGINT)", CURRENT_TIMESTAMP); ``` Let me know if it is feasible to do this way Please help me with this. Thanks