Vertica date/time function format

Moderator: NorbertKrupa

Post Reply
shaz001
Newbie
Newbie
Posts: 13
Joined: Mon Jan 13, 2014 1:08 am

Vertica date/time function format

Post by shaz001 » Tue Apr 22, 2014 6:45 pm

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

NorbertKrupa
GURU
GURU
Posts: 527
Joined: Tue Oct 22, 2013 9:36 pm
Location: Chicago, IL
Contact:

Re: Vertica date/time function format

Post by NorbertKrupa » Tue Apr 22, 2014 9:10 pm

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
Checkout vertica.tips for more Vertica resources.

Post Reply

Return to “Vertica Database Development”