Integer to time conversion

Database

Integer to time conversion

Hi,
I am facing a strange problem
i have a integer field which i want to convert in time as
91623-----09:16:23

when i am running below in sql assistant it is running fine
SEL CAST(92617 AS TIME);

09:26:17

but same query is giving error in BTEQ where i have to finally run it..
Please tell why this different behaviour is there and what is the solution to convert this in BTEQ also...

Regards,
Prakhar
2 REPLIES
Junior Supporter

Re: Integer to time conversion

You mast CAST to CHAR previous to CAST to TIME:

BTEQ -- Enter your DBC/SQL request or BTEQ command:
SELECT CAST ( CAST( TIME_INT AS CHAR(6)) AS TIME(0) FORMAT 'HHMISS')
FROM
( SELECT 91623 (FORMAT '999999') TIME_INT ) TEMP;

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

TIME_INT
--------
091623

HTH.

Cheers.

carlos.

Re: Integer to time conversion

Hi ,

You can try following query in BTEQ
select 92617 (FORMAT '99:99:99') (CHAR(8));

Sql Assistant Query
SELECT CAST(92617 AS TIME);

Hope this will help you.
Thanks
Ashwini W