Page 1 of 1

Vertica date/time function format

Posted: Tue Apr 22, 2014 6:45 pm
by shaz001
Hi,

I'm trying to insert current date, and current time into the following table and seems having formatting issues.

Could you provide examples how to format to enter values into DATE and TIMESTAMP columns using CAST or TO_CHAR functions.

create table t1 (dt DATE, ts TIMESTAMP);

insert into (CURRENT_DATE, CURRENT_TIMESTAMP);

Column "ts" is of type timestamp but expression is of type timetz
HINT: You will need to rewrite or cast the expression

Re: Vertica date/time function format

Posted: Tue Apr 22, 2014 9:10 pm
by NorbertKrupa
It seems like your issue is the INSERT syntax and missing parentheses on CURRENT_DATE. Also note that unless you're specifying precision, CURRENT_TIMESTAMP does not use parentheses.

Code: Select all

dbadmin=> INSERT INTO t1 (dt, ts) VALUES (CURRENT_DATE(), CURRENT_TIMESTAMP);
 OUTPUT
--------
      1
(1 row)

dbadmin=> SELECT * FROM t1;
     dt     |             ts
------------+----------------------------
 2014-04-22 | 2014-04-22 15:08:55.334903