请教SQL语句----关于求某列总和--------part two(50分)

冰封

Unregistered / Unconfirmed
GUEST, unregistred user!
如果是日期怎么写?
如果我有个表,其中有金额列和日期列,我要求出DateTimePicker1到DateTimePicker1的
金额总和怎么写?
select sum(heji) as sumr from 表
where xxxxxxxxxxxxx<-----这部分怎么写?
 
好象是 where limit DataTimePick1,DataTime....;
 
where time between DataTimePicker1.DateTime and DataTimePicker1.DateTime
 
to chenxz:
sql里是字符串,DataTimePicker1.DateTime写进去怎么能使用呢?!
 
用DateTimeToStr转换
where time between ' + DateTimeToStr(DataTimePicker1.DateTime) + ' and '
+ DateTimeToStr(DataTimePicker1.DateTime)
 
to chenxz:
这个我已经试过了,会说类型不匹配。
 
where time between #' + DateTimeToStr(DataTimePicker1.DateTime) + '# and #'
+ DateTimeToStr(DataTimePicker1.DateTime) +'#;'
 
那就转换为匹配的类型阿
 
to ysai:
不明白你写的意思,加#为何意?

to chenxz:
我就是不知道怎么转换,知道我就不问了。
 
你的日期是什么类型的,包括日期和时间?还是只有日期和只有时间?
如果只有日期就用DateToStr(DateTimePicker1.Date)
如果只有时间就用TimeToStr(DateTimePicker1.Time)
还有和什么样的数据库有关。

可能要用引号把值括起来,自己试试看
 
是单日期,函数我知道该怎么用。
加括号试了还是不行。
表是paradox 7。
 
//faint
paradox 7好像是要把日期中的“-”转换为“/”,自己转换一下看看
 
将时间格式化成类似这样的表达式:【01/01/2002 6:00 am】,然后用引号括起来。
如下:
select sum(heji) as sumr from 表 where DateTimePicker1 >= '01/01/2002 6:00 am'
and DateTimePicker1 <= '01/02/2002 6:00 pm'

 
顶部