Link to home
Start Free TrialLog in
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

asked on

Need help with a query

Hi Experts,

I want to check for the time difference between 2 times, if it is less than 2 min.

select StdLogID,StdTimeIn from LOGINDETAILS  where userID = @UserID and TodaysDate =FORMAT(GetDate(),'MMddyyyy') and
DATEDIFF(MINUTE, convert(varchar,StdTimeIn,120),convert(varchar,CURRENT_TIMESTAMP,120) < 2
and StdTimeIn IS NOT NULL and StdTimeout IS NULL)

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

ASKER

Thanks a lot.
Avatar of Jim Horn
Curiosity overwhelms me why you would want to convert a date to a varchar in order to perform a math expression...