Postgresql ignores milliseconds from timestamp when executing select statement
I have TableA and it has a Time | timestamp without time zone | default now () It is used to write when data has been inserted into the table. However, I'm trying to do a select and ignore milliseconds. Therefore, instead of
2015-07-11 18:06:33.690498
2015-07-12 13:36:21.274509
2015-07-12 13:36:24.222577
2015-07-12 13:36:26.515593
I would like to have
2015-07-11 18:06:33
2015-07-12 13:36:21
2015-07-12 13:36:24
2015-07-12 13:36:26
It takes microseconds in the table, but what I don't need is the output to output the microseconds. How can i do this? The closest I came up using the following, but I can't figure out how to output the complete date with time as shown above.
SELECT EXTRACT(YEAR FROM time_captured AT TIME ZONE 'UTC') FROM server_perf; date_part
Thank:)
+3
source to share
1 answer
You can use the date_trunc function to achieve this goal:
select date_trunc('second', time_captured) from server_perf;
see http://www.postgresql.org/docs/9.1/static/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC for more information on this.
+7
source to share