SQL 语句时间比较

View Code
--把字符轉換成日期型declare @dt1 varchar(20)
declare @dt2 varchar(20)
set @dt1='2009-9-01'
set @dt2='2009-10-01'
if @dt1>@dt2
print 'dt1大'
else
print 'dt2大'
if cast(@dt1 as datetime)>cast(@dt2 as datetime)
print 'dt1大'
else
print 'dt2大'
/*dt1大
dt2大
*/
posted @ 2011-07-08 15:50  Sue_娜  阅读(88)  评论(0编辑  收藏  举报