0

The answer to this isn't exactly what I wanted.

I have for example:

select to_timestamp(1476544839);
      to_timestamp      
------------------------
 2016-10-15 16:20:39+01
(1 row)

But I do not want the fractional part of seconds.

Expected:

      to_timestamp      
------------------------
 2016-10-15 16:20:39

PGSQL version:

 select version();
                                                               version                                                               
-------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.6.20 on x86_64-pc-linux-gnu (Ubuntu 9.6.20-1.pgdg18.04+1), compiled by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, 64-bit
(1 row)


EDIT

As a follow up to the question, I have this column named timestamp created with time zone.

> \d my_table;
                   View "postgres.my_table"
   Column   |           Type           | Collation | Nullable | Default 
------------+--------------------------+-----------+----------+---------
 session_id | integer                  |           |          | 
 timestamp  | timestamp with time zone |           |          | 
 seconds    | integer                  |           |          | 
...            ...

And so

SELECT timestamp FROM my_table
         timestamp          
----------------------------
 2016-03-17 08:33:51.842+00
 2016-03-17 08:33:51.738+00
 2016-03-17 08:33:50.794+00
(3 rows)

It is these fractional part of seconds .842 .739 .794 that I do not want.

arilwan
  • 3,374
  • 5
  • 26
  • 62

0 Answers0