Coverting INTEGER value to TIMESTAMP Format

Database
Enthusiast

Coverting INTEGER value to TIMESTAMP Format

I'm sorry. I'm disturbing your. I have a question about conversion of Integer to Timestamp.

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

I'm trying following query, but I get error.

select * from 

where a.BITIS_TARIHI >= CAST (20120301  AS TIMESTAMP FORMAT  'YYYY.MM.DD')

    and    a.BITIS_TARIHI < CAST(20120430 AS TIMESTAMP  FORMAT 'YYYY.MM.DD' )) )

Thanks in advance.

Ismail

2 REPLIES
Junior Contributor

Re: Coverting INTEGER value to TIMESTAMP Format

Hi Ismail,

there's only one recommended way to write dates avoiding potential problems due to typecasts or different formats:

DATE followed by a string 'YYYY-MM-DD'

Anything else might fail.

CAST(DATE '2012-03-01' AS TIMESTAMP)

or TIMESTAMP '2012-03-01 00:00:00'

Dieter

Enthusiast

Re: Coverting INTEGER value to TIMESTAMP Format

thanks Dieter.