Jump to content

SQL Subtracting Dates - Unit of Measure for Result?

Stephen Weiler

Recommended Posts

I'm subtracting one date from another, hopefully to determine the elapsed time between the two dates. The query completes, but I cannot determine the unit of measure for the result. I'm hoping to know the number of hours (rounded up) between these dates.


    h_dateresolved-h_datelogged Difference
from h_itsm_requests
limit 2

Does anyone know the default unit of measure?




Link to comment
Share on other sites

@Stephen Weiler good question. I would have said seconds, but that number is not the number of seconds between those dates... honestly I have no idea what the query does with that difference...

However, if you are after the number of hours between the two, use this: TIMESTAMPDIFF(HOUR, h_datelogged, h_dateresolved) AS difference

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...