Home How to select datetime where isnull value from SQL Server 2012?
Reply: 0

How to select datetime where isnull value from SQL Server 2012?

user855
1#
user855 Published in June 19, 2018, 6:21 pm

I have tb_user_log to collect user login and logout history and it has two cols (timein and timeout) but if the system error the timeout col is null value.

I need to select it and display even is null or not null.

I have below code but just returns only where value is not null and it hide the recode where timeout is null:

select *    
from tb_user_log 
where cast(Logintime as date) >= '2018-05-16' 
  and (cast(Logouttime as date) <= '2018-05-16' or
       cast(logouttime as date) <= '') 
order by id desc

Is any incorrect point in my code? It does not return the null recode.

Or any better way to select it? My datatype is datetime and I am using C# + SQL Server 2012.

Thank you.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.405238 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO