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

Hi @Jannette Jones
We have not received a response from you. Did the reply could help you? If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. By doing so, it will benefit all community members who are having this similar issue. Your contribution is highly appreciated.
Hi @Jannette Jones
We have not received a response from you. Did the reply could help you? If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. By doing so, it will benefit all community members who are having this similar issue. Your contribution is highly appreciated.