asp 按与当前时间最近的时间排序

来源:百度知道 编辑:UC知道 时间:2024/09/24 21:26:36
我的数据表中有这两个字段
intime 记录添加时间
days 记录有效期(单位是"天")

我现在想以即将到期时间排序,如还有1秒到期的排第一,还有2秒的排第二,……。请问该怎么写?

sql = "select * from 表名 order by DateAdd('d',days,intime) Asc"

select * from table order by dateAdd(d,days,intime) desc

sql = "select * from 数据表名 order by intime desc , days desc"

降序排列
升序用 BY ASC

select * from biao order by (datediff(day,intime,getdate())-days) desc