本文介绍了在SQL Server中均根据日期和时间进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下查询.vdate和vtime都是表中的varchar字段.

i have the following query.Both vdate and vtime are varchar fields in table.

select (isnull(RTRIM(LTRIM(CONVERT(varchar,convert(datetime,vdate,103),103))),'')+'  '+ isnull(REPLACE(REPLACE(RIGHT('0'+LTRIM(RIGHT(CONVERT(varchar,convert(datetime,vtime,103),100),7)),7),'AM',' AM'),'PM',' PM'),''))
as vdate from table1



它以"08/04/2013 03:00 AM"格式显示vdate列
当我按asc/desc顺序对记录进行排序时,它仅根据日期而不是时间对记录进行排序.我需要根据日期和时间对它们进行排序.我该怎么做?
请帮助..



which displays vdate column in "08/04/2013 03:00 AM" format
when i sort records in asc/desc order it sorts records according to date only and not the time.I need to sort them according to both date and time.How can i do this?
Plz Help..

推荐答案


这篇关于在SQL Server中均根据日期和时间进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 04:18