Reputation: 4047
I need to convert the ts field to a floating point number expressed in seconds
| ts | user_id | object_id |
+-------------------------------+---------+-------------+
| 2016-08-12 15:13:34.898779+01 | 12 | 5 |
The same format that can be achieved with
import time
ts = time.time()
print ts #1507023571.12
So, my question is How can I convert the ts field?
Upvotes: 0
Views: 63
Reputation: 51456
use epoch
:
t=# select extract(epoch from now()), now();
date_part | now
------------------+-------------------------------
1507024254.74876 | 2017-10-03 09:50:54.748764+00
(1 row)
edit
use smth like: select extract(epoch from ts) ts from reputation_log
Upvotes: 1