Date Format Problem

Tools & Utilities
Enthusiast

Date Format Problem

Hi There,

I am trying to format my SQL query but Date format is not working.
I want to see the Date format like YY-MM-DD
Here is my query. Please help

sel EDATE( FORMAT 'YY-MM-DD') from EMP
5 REPLIES
Enthusiast

Re: Date Format Problem

I'm fairly new to Teradata (background in SPSS and data mining). This CAST statement has worked well for me;

CAST(my_dt AS DATE FORMAT 'YYYY-MM-DD') AS my_new_dt

I also used this to get date difference;

(my_dt - CAST('2006-06-01' AS DATE FORMAT 'YYYY-MM-DD')) AS my_tenure

Hope this helps,

Cheers

Tim
Enthusiast

Re: Date Format Problem

Are you using SQL Assistant ? ODBC doesn't cope with Formatting.
Enthusiast

Re: Date Format Problem

How about this, which WILL work with ODBC...(courtesy of my mate Andy)..

select cast(cast(date as date format 'YY-MM-DD') as char(8)) ;
Enthusiast

Re: Date Format Problem

select cast( (date (format 'YY-MM-DD')) as char(10)) ;
Enthusiast

Re: Date Format Problem

it worked for me in bteq and SQL assistant too. Can you try it this way.

select date (format 'yy-mm-dd');
select date (format 'yy-mm-dd');

*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.

Date
--------
06-08-25