In
Tearadata time difference calculation is bit tricky compared to SQL Command DateDiff(HH, Date1, Date2)
So
here is Syntax/ Code for calculating Time difference in Hours between Today's date and EventDate
Syntax:
SELECT
CAST( CURRENT_DATE AS TIMESTAMP(6)) -- Today's Date
, EventDate -- Date you want to check with
,(CAST(EventDate AS
TIMESTAMP(6)
)- CAST(CURRENT_DATE
AS TIMESTAMP(6) )) DAY(4) TO MINUTE AS DHM -- Time difference
in Days Hours:Minutes
,24* EXTRACT(DAY FROM (DHM)) -- Hours
calculation by Days
,EXTRACT(HOUR FROM (DHM)) -- extracting
extra hours from apart from complete day
,24* EXTRACT(DAY FROM (DHM)) + EXTRACT(HOUR FROM (DHM)) AS HoursDiff -- Exact
Time difference in Hours
FROM Database.TableName
SELECT (EndDTTM-StartDTTM) DAY(4) TO SECOND(6) AS diff_DDHHMM,
ReplyDeleteEXTRACT(DAY FROM diff_DDHHMM) * 24*60
+ EXTRACT(HOUR FROM diff_DDHHMM) * 60
+ EXTRACT(MINUTE FROM diff_DDHHMM) AS Total_Minutes,
FROM TableName