Time Difference in Minutes

CASE
WHEN Hospital Ready Time (UTC) IS NOT NULL AND Video Start Time (UTC) IS NOT NULL THEN
ABS(UNIX_TIMESTAMP(Hospital Ready Time (UTC)) - UNIX_TIMESTAMP(Video Start Time (UTC))) / 60
ELSE NULL
END

I am trying to find the difference between 2 timestamps. I am using the above beast mode calculation but it is giving me syntax error. Can anyone please help?

Best Answer

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    You can simplify your beast mode. If either of your fields are NULL then the entire subtraction will be NULL.

    (UNIX_TIMESTAMP(`Hospital Ready Time (UTC)`) - UNIX_TIMESTAMP(`Video Start Time (UTC)`)) / 60 
    

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**

Answers

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    You can simplify your beast mode. If either of your fields are NULL then the entire subtraction will be NULL.

    (UNIX_TIMESTAMP(`Hospital Ready Time (UTC)`) - UNIX_TIMESTAMP(`Video Start Time (UTC)`)) / 60 
    

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**