SQL的Between...And...使用问题!

poctopus 2004-03-31 06:45:24
在定义时间后,在SElect语句中如何在Between....And....中使用!!

syear=request("s-year")
smonth=request("s-month")
sdate=request("s-date")
eyear=request("e-year")
emonth=request("e-month")
edate=request("e-date")

sdata=smonth&"/"&sdate&"/"&syear
edata=emonth&"/"&edate&"/"&eyear


select sum(cc_confirm) from zonghe where cc_date between ????? and ???????
...全文
57 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
poctopus 2004-04-01
  • 打赏
  • 举报
回复
<%
syear=request("s-year")
smonth=request("s-month")
sdate=request("s-date")
eyear=request("e-year")
emonth=request("e-month")
edate=request("e-date")

sdata=smonth&"/"&sdate&"/"&syear
edata=emonth&"/"&edate&"/"&eyear

dim conn
dim connstr
on error resume next
connstr="DBQ="+server.mappath("/database/cc.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr

'统计验货总数
'select sum(money) from 表 group by datepart(quarter,reg_date)
'按月:select sum(money) from 表 group by datepart(day,reg_date)
'select sum(总收入),avg(平均收入) from tablename where 时间=(年或季度或月)
'rs(0)为总收入
'rs(1)为平均收入


rs=conn.execute ("select sum(cc_confirm),sum(cc_del),sum(cc_fmp),sum(cc_tsdd),sum(cc_ci),sum(cc_co) from zonghe where cc_date between '"(sdata)&"' and '"&trim(edata)&"'")

%>
poctopus 2004-04-01
  • 打赏
  • 举报
回复
还是有问题!以上的解决方法均无法解决。

我把程序贴上来,大家看看如何解决。Between.....and......之间的时间应该用#号。
如:
Between #03/01/04# and #03/31/04#



chenrong0406 2004-04-01
  • 打赏
  • 举报
回复
以上都说完了.我没得说了,只能顶一下了
poctopus 2004-04-01
  • 打赏
  • 举报
回复
顶一下
anddytang 2004-03-31
  • 打赏
  • 举报
回复
sdata=smonth&"/"&sdate&"/"&syear
edata=emonth&"/"&edate&"/"&eyear
sdata=CDate(sdata)
edata=CDate(edata)

select sum(cc_confirm) from zonghe where cc_date between '"&sdata&"'
and '"&edata&"'
Miriamy 2004-03-31
  • 打赏
  • 举报
回复
sql="select sum(cc_confirm) from zonghe where cc_date between '"&sdata&"' and '"&edata&"'"
银狐被占用 2004-03-31
  • 打赏
  • 举报
回复
s_sql="select sum(cc_confirm) from zonghe where cc_date between '"&trim(sdata)&"' and '"&trim(edata)&"'"
mesher 2004-03-31
  • 打赏
  • 举报
回复
sql="select sum(cc_confirm) from zonghe where cc_date between '"&sdata&"' and '"&edata&"'"

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧