怎么就是没人回答我?50分够吗?谢谢大家!

iketeng 2003-08-23 11:16:56
小弟最近刚刚接触VC数据库开发!请大家多指点

程序中看见这样一段SQL语句,这段语句在ACCESS中无法执行,仔细看了以后
发现好象那个日期符号的问题,但是又没有把握,所以就麻烦大家帮我看一下。

{"Select sum(fee) as sumfee, count(patientid) as countid from study where
studydate between '2003-7-22' and dateadd( day, 1, '2003-7-22')"}

我注意到日期那里用的是单引号,这样的话是不是在ACCESS数据库就无法执行了?如果是
这样的话,我是不是应该修改成:

{"Select sum(fee) as sumfee, count(patientid) as countid from study where
studydate between #2003-7-22# and dateadd( day, 1, #2003-7-22#)"}

如果不该这样修改,我该改成什么样子?
...全文
29 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
iketeng 2003-08-24
  • 打赏
  • 举报
回复
谁能接着雨露的话来帮我啊?谢谢啦!
yanzai8848 2003-08-24
  • 打赏
  • 举报
回复
Select sum(fee) as sumfee, count(patientid) as countid
from study
where studydate between CDate('2003-6-23')
and CDate('2003-7-23')
------------- or-----------------
Select sum(fee) as sumfee, count(patientid) as countid
from study
where studydate >= CDate('2003-6-23')
and studydate <= CDate('2003-7-23')

上述SQL语句语法完全正确,使用一些SQL测试工具测试一下结果吧,也许是其他地方出错了。
iketeng 2003-08-23
  • 打赏
  • 举报
回复
雨露,感谢你的回复!我修改了程序,你给的第二第三个都不能执行!

只有用第一个可以执行,但是得到的值却是错的!不知为什么!

和你详细说一下我这个语句使用的地方和用途吧!

我是在用VC做一个报表程序,这段代码是在做“比较类”报表时使用的!

我的意图是对比指定时间段内得到的数值。我用你给我的第一个语句,对比2003-6-23和2003-7-23的数据时得到的结果是:

2003-6-23 23
2003-7-23 128

但是我用SQL数据库对比时得到的正确值却是:

2003-6-23 83
2003-7-23 277

显然你的语句是正确的,但是不知为什么却不能得到正确的数值呢?感谢你的指导!!
李秀国之印 2003-08-23
  • 打赏
  • 举报
回复
Select sum(fee) as sumfee, count(patientid) as countid from study where
studydate between 2003-7-22 and 2003-7-22
李秀国之印 2003-08-23
  • 打赏
  • 举报
回复
Select sum(fee) as sumfee, count(patientid) as countid from study where
studydate between ('2003-7-22') and ('2003-7-22')
李秀国之印 2003-08-23
  • 打赏
  • 举报
回复
Select sum(fee) as sumfee, count(patientid) as countid from study where
studydate between CDate('2003-7-22') and CDate('2003-7-22')
iketeng 2003-08-23
  • 打赏
  • 举报
回复
啊?是吗?难怪我改成#也没用!

谢谢你啊!对问您一句,那我该怎么实现啊?实在太谢谢了!
思危 2003-08-23
  • 打赏
  • 举报
回复
dateadd 这个函数ACCESS不支持
iketeng 2003-08-23
  • 打赏
  • 举报
回复
SoLike(是我)!能不能详细说说我的那个语句该怎么改啊?万分感谢!
思危 2003-08-23
  • 打赏
  • 举报
回复
ACCESS的时间用 #时间# 隔离,我在Delphi中是这样的

VC中应该也一样吧
flinming 2003-08-23
  • 打赏
  • 举报
回复
up
iketeng 2003-08-23
  • 打赏
  • 举报
回复
大哥?对是什么意思?能不能说的详细一点?
mjznet 2003-08-23
  • 打赏
  • 举报
回复

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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