方式一:CONVERT(varchar(10), TransDateTime, 20) //存在隐患
方式二:CONVERT(varchar(100), GETDATE(), 23) //建议使用
eg:日期截取配合group by使用:
select MemberID,Convert(varchar(10),BetDateTime,20) AS Date,SUM(ValidBetAmount) AS ValidBetAmount from Lambor_Game.dbo.GameRecord
where MemberID in (159997,155951,159999) And BetDateTime between '2020/4/5 0:00:00' and '2020/4/7 23:59:59'
Group by MemberID,CONVERT(varchar(10),BetDateTime,20)