DateTime Function Format @ Conversion of SQL Server Query to Teradata Query

Database
Enthusiast

DateTime Function Format @ Conversion of SQL Server Query to Teradata Query

Hello everyone,

I'm sorry. I'm disturbing your. I have a question about conversion of SQL Server Query to Teradata Query about DateTime function.

If anyone can help me in conversion of query to teradata;

SELECT 

replace(convert(varchar(10),convert(datetime,convert(varchar ,(lk.DATECOLUMN+1)),110),111),'/','-') as COLUMNDATE

FROM    TABLE  lk

By the way, date formats;

110 >>> 07-13-2012  (MM-DD-YYYY)

111 >>> 2012/07/13 (YYYY/DD/MM)

Thanks in advance

Best Regards;

ISMAİL ARSLAN

1 REPLY
Junior Supporter

Re: DateTime Function Format @ Conversion of SQL Server Query to Teradata Query

ISMAİL:

Either I don't get it or the query does not make sense even in SQLServer...

It seems you are looking for a final string (VARCHAR) with format YYYY-MM-DD. In this case:

SELECT CAST(CAST(DATECOLUMN+1 AS FORMAT 'YYYY-MM-DD') AS VARCHAR(10)) FROM lk;

should suffice.

btw: In Teradata DATEs are DATEs, no DATETIMEs. If your data is DATETIME you should use a TIMESTAMP in Teradata, and the '+1' arithmetics should be:

SELECT CAST(CAST(DATECOLUMN+CAST(1 AS INTERVAL DAY) AS FORMAT 'YYYY-MM-DD') AS VARCHAR(10)) FROM lk;

HTH.

Cheers.

Carlos.