TERADATA dates

Database
Enthusiast

TERADATA dates

Just wondering,

 

In teradata sometimes you can compare a date by putting mydate<= '2012-05-09'

And sometimes above dont work and then if you convert the date into teradata date it will work?   mydate <= 1120509

I dont have a particular example but that's what i have experienced.

 


Accepted Solutions
Highlighted
Junior Contributor

Re: TERADATA dates

'2012-05-09' is a string literal, not a date and thus it's automatically casted to a date using the FORMAT of the mydate column.

 

Instead of the old syntax 1120509 (which is hard to understand) you should use a Standard SQL Date Literal which is DATE followed by 'YYYY-MM-DD' string: 'DATE '2012-05-09' 

 

1 ACCEPTED SOLUTION
1 REPLY
Highlighted
Junior Contributor

Re: TERADATA dates

'2012-05-09' is a string literal, not a date and thus it's automatically casted to a date using the FORMAT of the mydate column.

 

Instead of the old syntax 1120509 (which is hard to understand) you should use a Standard SQL Date Literal which is DATE followed by 'YYYY-MM-DD' string: 'DATE '2012-05-09'