i have data in sql server 2008 format date
checktime 2016-08-10 10:21:03.000 2016-08-10 10:15:42.000 then search date today
select [dbo].[checkinout].[userid],checktime,[dbo].userinfo.name [dbo].[checkinout] inner join [dbo].[userinfo] on [dbo].userinfo.userid = [dbo].checkinout.userid checkinout.checktime '%2016%' order checkinout.checktime desc is working , shows 2016 dates. if change selection like '%2016-08-08' nothing returned.
i try condition:
where checkinout.checktime = '2016-0-08' nothing returned...
any clue problem? show data today.
thanks
yes first clue 2016-0-08 wrong. there no such thing month = 0.
second, [checkinout].checktime in format 2016-08-08 10:21:03.000 , comparing '2016-08-08'. result false.
try converting [checkinout].checktime varchar using appropriate format match '2016-08-10'
i used dateformat 120 yyyy-mm-dd hh:mi:ss , takes first 10 letters using varchar(10). yyyy-mm-dd. more date formats
select [dbo].[checkinout].[userid],checktime,[dbo].userinfo.name dbo.[checkinout] inner join [dbo].[userinfo] on [dbo].userinfo.userid = [dbo].checkinout.userid convert(varchar(10),checkinout.checktime,120) = '2016-08-08' order checkinout.checktime desc
Comments
Post a Comment