Hi. SQL 2008R2
I have 2 dates like 2018-05-18 21:04:44.717 and 2018-05-18 21:04:44.917
I want to get rid of the seconds milliseconds part .
Doing this convert(varchar,thedate,120) as mydate
and grouping by thedate as convert(varchar,thedate,120) will group it but if there is a second difference then it will not group it.
So I would need something like this (that will not work but is to give you a clue)
select convert(varchar,thedate,120) as mydate
group by convert(varchar,thedate,112) -- yyyymmdd
Of course this will complain.
I don't want to go to overcomplicated solutions with tables grouping tables grouping tables.
Is there a simple solution?
Thanks.
That code should truncate, not round, which is what you want to do. That keeps the value within whatever minuted it started in. For example, if the time is 1:59:59PM, the above code should include it in 1:59PM.