I want to calculate the currently logged in users for which i tried the below query:
select COUNT(*)from [dbname]
where login_time < SYSDATETIME()
and logout_time is NULL
But i want to get the records for only current date so i tried :
select COUNT(*)from [dbname]
where ( SYSDATETIME()-1) < login_time < SYSDATETIME()
and logout_time is NULL
This seems to be incorrect. So how to form the query properly? I cant use GETDATE() or Datetime.now() as it will give the secs as well which wont match with the datetime in the database