关于查询的问题,to_date(lrrq)=操作员选择的日 找财务软件
库存管理软件版1楼: cx1.Close;
cx1.SQL.clear;
cx1.SQL.text:=''select to_char(a.service_kind) 网别,to_char(sum(a.qfje)) 欠费金额 from ''+
''(select account_id,service_kind ,to_char(qfje) qfje from zxd_chengde_cuifei_qf where ''+
''to_date(lrrq)=:b ''+
''group by account_id,service_kind,to_char(qfje)) a group by a.service_kind'';
cx1.Parameters.ParamByName(''b'').Value :=Dtp1.date;
cx1.Open;
''(select account_id,service_kind ,to_char(qfje) qfje from zxd_chengde_cuifei_qf where ''+
''lrrq>=:a AND lrrq<:b ''+
''group by account_id,service_kind,to_char(qfje)) a group by a.service_kind'';
cx1.Parameters.ParamByName(''a'').Value :=TRUNC(Dtp1.date);
cx1.Parameters.ParamByName(''b'').Value :=TRUNC(Dtp1.date)+1;
cx1.Open;
cx1.SQL.clear;
cx1.SQL.text:=''select to_char(a.service_kind) 网别,to_char(sum(a.qfje)) 欠费金额 from ''+
''(select account_id,service_kind ,to_char(qfje) qfje from zxd_chengde_cuifei_qf where ''+
''to_date(lrrq)=:b ''+
''group by account_id,service_kind,to_char(qfje)) a group by a.service_kind'';
cx1.Parameters.ParamByName(''b'').Value :=Dtp1.date;
cx1.Open;
2楼: 请看一下错在哪里了。 如客户管理软件
3楼: 1、lrrq是日期型,不需要 to_date
2、lrrq及Dtp1.date都含有时分秒,上面直接相等的方式取得的结果可能会与实际不一致
4楼: to_char和to_date用法是这样的
to_date(''20060101'',''yyyymmdd'')=llrq
to_char(llrq,''yyyymmdd'')=''20060101''
5楼: 如果要用to_char(lrrq,''yyyy-mm-dd'')=dtp1.date为什么系统总提示yyyy-mm-dd出错,我已把dtp1设为yyyy-MM-dd了,请指教。
6楼: cx1.Close;
cx1.SQL.clear;
cx1.SQL.text:=''select to_char(a.service_kind) 网别,to_char(sum(a.qfje)) 欠费金额 from ''+
''(select account_id,service_kind ,to_char(qfje) qfje from zxd_chengde_cuifei_qf where ''+
''lrrq>=:a AND lrrq<:b ''+
''group by account_id,service_kind,to_char(qfje)) a group by a.service_kind'';
cx1.Parameters.ParamByName(''a'').Value :=TRUNC(Dtp1.date);
cx1.Parameters.ParamByName(''b'').Value :=TRUNC(Dtp1.date)+1;
cx1.Open;
库存管理软件版7楼: 谢谢!现在无错误提示了,但执行出错为“月份中的日必需介于1和当月最后一日之间”怎么办。
8楼: 不是这儿的错误吧
你的日期越界了,比如 1月32号等等
9楼: 在delphi中可以这样用吗to_char(lrrq,''yyyy-mm-dd'')>=:a and to_char(lrrq,''yyyy-mm-dd'')<=:b
10楼: 你那是ORACLE的查询语句啦,DELPHI的函数例如:formatdatetime这个是很方便的。
11楼: 尽量不要用to_char,因为你加上to_char后无法利用索引
12楼: cx1.Parameters.ParamByName(''b'').Value :=QuotedStr(Dtp1.date); 如财务软件