Substracting two TIME(6) datatype values

General
Enthusiast

Substracting two TIME(6) datatype values

HI

    I have two columns Start_Time and End_Date in a table with data type TIME(6) and i want to substract the two values in a stored Procedure.

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 6526 StartFragment: 314 EndFragment: 6494 StartSelection: 314 EndSelection: 314

 SELECT Log_Time INTO vStart FROM DB.LOG_TABLE

SELECT Log_Time INTO vEnd FROM DB.LOG_TABLE


SET vTotal = CAST( CAST(vEnd AS CHAR(6) ) AS INTERVAL HOUR TO SECOND(6) ) -CAST( CAST(vStart AS CHAR(6) ) AS INTERVAL HOUR TO SECOND(6) ) ;

When i try to perform the substraction i get the error '

Invalid or missing expression 'E(5407):Invalid operation for DateTime or Interval.'. Please help me.

 

-Arun

Tags (1)
1 REPLY
Junior Supporter

Re: Substracting two TIME(6) datatype values

 BTEQ -- Enter your SQL request or BTEQ command:
SELECT CAST('22:22:00' AS TIME(0)) - CAST('22:00:00' AS TIME(0)) HOUR(2) TO SECOND(0) ;

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

('22:22:00' - '22:00:00') HOUR TO SECOND
----------------------------------------
0:22:00

Cheers.

Carlos.