当前位置: 代码迷 >> ASP >> sql 日期时间有关问题
  详细解决方案

sql 日期时间有关问题

热度:78   发布时间:2012-08-08 14:32:45.0
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')
  相关解决方案