Search Postgresql Archives

hrs, mins and seconds do not appear with to_char

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Hi

I am unsure as to why the hrs, mins and seconds do not appear for a date column. I am using PostgreSQL 9.6.3 on Linux.
When performing the exact same queries in Oracle, I get the full date formatted to "yyyymmddhh24miss", but cannot get the same for PostgreSQL, for example:

ft_node=# create table t3 (a numeric, b varchar(10), d date);
CREATE TABLE
ft_node=# insert into t3 values (1,'Yellow', to_date('20170827121212','yyyymmddhh24miss'));
INSERT 0 1
ft_node=# insert into t3 values (2,'Red', to_date('20170827121213','yyyymmddhh24miss'));
INSERT 0 1
ft_node=# select a,b,to_char(d,'YYYYMMDDHH24MISS') as d from t3;
 a |   b    |       d        
---+--------+----------------
 1 | Yellow | 20170827000000
 2 | Red    | 20170827000000
(2 rows)


In Oracle I get the following:
SQL> create table t3 (a numeric, b varchar(10), d date);

Table created.

SQL> insert into t3 values (1,'Yellow', to_date('20170827121212','yyyymmddhh24miss'));

1 row created.

SQL> insert into t3 values (2,'Red', to_date('20170827121213','yyyymmddhh24miss'));

1 row created.

SQL> commit;

Commit complete.

SQL> select a,b,to_char(d,'yyyymmddhh24miss') as d from t3;

A B      D
---------- ---------- --------------
1 Yellow     20170827121212
2 Red      20170827121213


As you can see, the hrs, mins and seconds appear as was inserted in Oracle, but not for PostgreSQL. Any suggestions?

Thanks
P


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux