user2711819
user2711819

Reputation: 960

Insert current date Teradata

SELECT  DATE(FORMAT 'yyyy-mm-dd') (CHAR(10)) --2013-12-12

SELECT  DATE(FORMAT 'yyyy-mm-dd') --12/12/2013

I like to insert data into table in this format

insert into emp values ( DATE(FORMAT 'yyyy-mm-dd') (CHAR(10)) ,...... )

can you tell me how to insert current date into table in this format ? yyyy-mm-dd

Upvotes: 0

Views: 7574

Answers (2)

dnoeth
dnoeth

Reputation: 60502

What is your actual problem? FORMAT is mainly used for CASTs from/to a string, but the internal datatype DATE is not stored in any dmy/ymd format.

If the target column is defined as a DATE you can simply insert DATE/CURRENT_DATE without applying a FORMAT to it.

Your 2nd example showing a wrong result is probably submitted using SQL Assistant, which is using its own formating rules based on Options -> Data Format -> "Display dates in this format".

Your INSERT will be correct for a CHAR target column, but you shouldn't store dates in a CHAR :-)

Upvotes: 1

user2711819
user2711819

Reputation: 960

CYCLEDATE DATE FORMAT 'YYYY-MM-DD'    --- TABLE DEFINITION

Insert into emp cycledate values ( date ) -- worked . 

Upvotes: 0

Related Questions