asp关于时间问题

harrizon 2004-11-22 11:30:03
在access 数据库有字段id,date1,value1,
保存的值是
1,2004-11-14,5
2,2004-11-10,6
3,2004-11-19,2
.....

现在想要知道和今天相比,日期的天数差,然后除以这个value1排序
比如上面
和今天2004-11-22相比,天数差别分别是
8
12
3
,
除以value1就是1.6,2,1.5


所以排序结果就是
2,2004-11-10,6
1,2004-11-14,5
3,2004-11-19,2

就是希望这样子显示出来
请问如何处理?
能否使用一句sql处理
...全文
131 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
harrizon 2004-11-22
sql="select *,datediff('d',date1,now())/value1 as ord from test order by ord desc"

Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e10'

[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。
回复
davs 2004-11-22
sql="select *,datediff('d',date1,now())/value1 as ord from test order by ord desc"
呵呵,忘了是ACCESS,
回复
harrizon 2004-11-22
Microsoft VBScript 编译器错误 错误 '800a0401'

语句未结束

sql="select *,datediff("d",date1,now())/value1 as ord from test order by ord desc"
------------------------^



sql="select *,datediff(d,date1,now())/value1 as ord from test order by ord desc"
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 2。



回复
harrizon 2004-11-22
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC Microsoft Access Driver] 表达式中 'getdate' 函数未定义。
回复
liuyangxuan 2004-11-22
datediff("d",date,date())/value1 as 新变量 即可
回复
未来 2004-11-22
select datediff("d",date1,date())/value1 as value2 form test order by value2 desc
ACCESS中d要加双引号,SQL SERVER中d不要加。
回复
hushuang7094 2004-11-22
差不多
select datediff("d",date1,date())/value1 as value2 form test order by value2 desc
回复
tatty_bad 2004-11-22
select *,datediff(d,date1,getdate())/value as ord from test order by ord desc

这位老兄给的SQL的

select *,datediff(d,date1,Now())/value as ord from test order by ord desc

这个是Access的
回复
ygjwjj 2004-11-22
select id,date1,value1,datediff(d,date1,getdate())/value as ord from test order by ord desc
回复
davs 2004-11-22
select *,datediff(d,date1,getdate())/value as ord from test order by ord desc
回复
harrizon 2004-11-22
sql="select *,datediff('d',date1,now())/value1 as ord from test order by datediff('d',date1,now())/value1 desc"

这样子可以了

多谢各位
回复
harrizon 2004-11-22
sql="select *,datediff('d',date1,now())/value1 as ord from test"
这个正常
但是
sql="select *,datediff('d',date1,now())/value1 as ord from test order by ord desc"
就出错
为何呢?!
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-11-22 11:30
社区公告
暂无公告