日期:2014-05-18  浏览次数:20328 次

数值比较(SQL+ASP)
我想实现这样个功能:
表中有时间字段,200705090955,表示2007年5月9号9点55分
我要让当前的时间和表中的时间进行比较,如果当前时间大于表中的时间则执行另一个程序,否则不执行。
程序应该如何写?怎样比较?
怎样将库里的200705090955取出来和当前时间比较,还要转换一下格式?


------解决方案--------------------
declare @dt datetime
declare @now datetime

select @dt=convert(datetime,stuff(stuff(stuff(stuff( '200705090955 ',5,0, '- '),8,0, '- '),11,0, ' '),14,0, ': '),120)
select @now=convert(datetime,convert(varchar(16),getdate(),120),120)

if @dt <@now
--执行1
else
--执行2