Monday, March 26, 2018

Select = date without timestamp with sql

you may have a data for date column with timestamp
eg: 2018-03-26 13:40:22.470

let's say you need to check the date eg: 2018-03-26

Then you need to take part of the date string. you have various options, here i use convert()

 select count(*)
  -- convert(varchar(10),LastErrorOccurredDate,120)
 from Mytable (nolock)
 where convert(varchar(10),LastErrorOccurredDate,120) ='2018-03-26'

No comments:

Post a Comment