I have a SQL query that I'm trying to find the time difference between two date fields. I need to have min column positive numbers otherwise the user would get confused.
My query
SELECT
tblMove.intProp,
tblCustomerSpaces.strSpace,
tblCustomerSpaces.intCustSpace AS intCustSpaceMoveOut,
CAST(SWITCHOFFSET(tblMove.dtMove, DATENAME(tz, tblMove.dtMove)) as datetime) AS dtMoveOut,
tblCustomer.strLName AS strMOLast,
tblListMoveOutReasons.strReason,
qryNextMoveIn.dtMoveIn,
qryNextMoveIn.intCustSpaceMoveIn,
qryNextMoveIn.strLName AS strMILast,
tblMove.fltSpaceTypeOcc,
DATEDIFF(hh, CAST(SWITCHOFFSET(tblMove.dtMove, DATENAME(tz, tblMove.dtMove)) as datetime), qryNextMoveIn.dtMoveIn) AS intHours,
DATEPART(MINUTE,tblMove.dtMove) - DATEPART(MINUTE,qryNextMoveIn.dtMoveIn)as 'minutes difference',
qryNextMoveIn.strDescription
FROM
tblMove WITH (NOLOCK)
INNER JOIN tblCustomerSpaces WITH (NOLOCK) ON tblMove.intProp = tblCustomerSpaces.intProp AND tblMove.intCustSpace = tblCustomerSpaces.intCustSpace
INNER JOIN tblCustomer WITH (NOLOCK) ON tblCustomerSpaces.intProp = tblCustomer.intProp AND tblCustomerSpaces.intCustNumb = tblCustomer.intCustNumb
Inner join tblListMoveOutReasons WITH (NOLOCK)
ON tblMove.intMOReason = tblListMoveOutReasons.intReason
![User's image](https://learn-attachment.microsoft.com/api/attachments/f8999595-5823-49c8-b131-01496b4cb319?platform=QnA)