日期:2014-05-17  浏览次数:20924 次

sql 日期时间问题
数据库中有两个字段 类型为nvarchar
字段A为日期 字段B为时间
当前日期时间为C
用sql语句如何将A和B连接起来和C做对比,来读出数据库中的记录
在ASP中使用
Select * from table where A+B>=C 这样显然是不行的。如何转换。谢谢!

------解决方案--------------------
SQL code

select * from yourtable where convert(datetime,A+' '+B)>=C

------解决方案--------------------
什么数据库?
MSSQL
select * from yourtable where cast((A+' '+B) as datetime)>=C

Access 转换字串到日期的函数是format,格式是

format(A+' '+B,'yyyy-mm-dd HH:mm:ss')