SELECT year(indagatedate),month(indagatedate),day(indagatedate),datepart(hour,indagatedate),datepart(minute,indagatedate),datepart(second,indagatedate)
order by year(indagatedate),month(indagatedate),day(indagatedate),datepart(hour,indagatedate),datepart(minute,indagatedate),datepart(second,indagatedate) desc
查询表中数据,按年月日,时分秒排序,由于库中的时间字段精确到毫秒了,只能想到拆分了
但是降序排序后,得到的数据还是升序的
如果把后面的时、分、秒去掉,只保留前面的年、月、日则获取的数据是正确的(降序了)
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','') --20111205155448把他们全部转化为数字