|
CASE WHEN ( PODT00 > 0 ) THEN CASE WHEN ( PODT00 - SDDT00 ) < 0 THEN 0 WHEN SDTM00 = 1700 THEN 0 WHEN SDTM00 < POTM00 THEN CAST ((CAST(CAST(CONCAT(CONCAT(CONCAT(SUBSTRING(CAST((CASE WHEN SDTM00 > 1259 THEN (CAST(CONCAT(SUBSTR(CAST(SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END ) AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN SDTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN SDTM00 < 1200 THEN ' AM' ELSE ' PM' END ) ) AS TIME ) - CAST ( CONCAT ( CONCAT ( CONCAT ( SUBSTRING ( CAST ( ( CASE WHEN POTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE POTM00 END ) AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN POTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE POTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( POTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( POTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN POTM00 < 1200 THEN 'AM' ELSE ' PM' END ) ) AS TIME ) AS NUMERIC ( 8 , 0 ) ) / 100 ) AS NUMERIC ( 8 , 0 ) ) ELSE 0 END WHEN ADTM00 > 0 THEN CASE WHEN ( ADDT00 - SDDT00 ) < 0 THEN 0 WHEN SDTM00 = 1700 THEN 0 WHEN SDTM00 < ADTM00 THEN CAST ( ( CAST ( CAST ( CONCAT ( CONCAT( CONCAT ( SUBSTRING ( CAST ( ( CASE WHEN SDTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END ) AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN SDTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE SDTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( SDTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN SDTM00 < 1200 THEN ' AM' ELSE ' PM' END ) ) AS TIME ) - CAST ( CONCAT ( CONCAT ( CONCAT ( SUBSTRING ( CAST ( ( CASE WHEN ADTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE ADTM00 END ) AS VARCHAR ( 4 ) ) , 1 , ( CASE WHEN LENGTH ( CAST ( ( CASE WHEN ADTM00 > 1259 THEN ( CAST ( CONCAT ( SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 1 , 2 ) , SUBSTR ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , 3 , 2 ) ) AS NUMERIC ( 4 , 0 ) ) - 1200 ) ELSE ADTM00 END ) AS VARCHAR ( 4 ) ) ) = 3 THEN 1 ELSE 2 END ) ) , ':' ) , SUBSTRING ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) , ( CASE WHEN LENGTH ( CAST ( ADTM00 AS VARCHAR ( 4 ) ) ) = 3 THEN 2 ELSE 3 END ) , 2 ) ) , ( CASE WHEN ADTM00 < 1200 THEN ' AM' ELSE ' PM' END ) ) AS TIME ) AS NUMERIC ( 8 , 0 ) ) / 100 ) AS NUMERIC ( 8 , 0 ) ) ELSE 0 END ELSE 0 END AS TIMEDIF
|