Fórum Consulta entre datas com SQL #219992
11/03/2004
0
Preciso fazer uma consulta aonde a data inicial e final sao passadas por parametro. O codigo SQL está correto. O problema é o seguinte.
Tenho dois componentes datapicker para a escolha das datas. Mas ele retorna por exemplo dd/mm/aaaa. É preciso que ele retorne aaaa/mm/dd, pois senao nao funciona com mysql.
o código é o seguinte:
dm.tb_oper.IndexName := ´ind_dtemprestimo´;
with dm.comSomaQuery do
begin
Active := false;
sql.Clear;
sql.add(´select b.nome_cliente, b.cpf, a.vr_pedido, a.qt_parcelas, a.vr_parcela,´);
sql.Add(´a.refinanciamento from tb_oper a, tb_cliente b, tb_fin c where refinanciamento=´N´ and c.cod_fin=a.cod_fin and´);
sql.add(´c.nome_fin like:var and a.dt_emprestimo between :var2 and :var3 and a.cod_cliente=b.cod_cliente order by a.dt_emprestimo´);
Params[0].Value := ´¬BMG¬´;
Params[1].Value := datetostr(comissao.dtini.Date);
Params[2].Value := datetostr(comissao.dtfin.Date);
Active := true;
open;
end;
Se alguem sabe como formatar a data do datapicker para aaaa/mm/dd eu agradeço.
[]´s
Danielle
Tenho dois componentes datapicker para a escolha das datas. Mas ele retorna por exemplo dd/mm/aaaa. É preciso que ele retorne aaaa/mm/dd, pois senao nao funciona com mysql.
o código é o seguinte:
dm.tb_oper.IndexName := ´ind_dtemprestimo´;
with dm.comSomaQuery do
begin
Active := false;
sql.Clear;
sql.add(´select b.nome_cliente, b.cpf, a.vr_pedido, a.qt_parcelas, a.vr_parcela,´);
sql.Add(´a.refinanciamento from tb_oper a, tb_cliente b, tb_fin c where refinanciamento=´N´ and c.cod_fin=a.cod_fin and´);
sql.add(´c.nome_fin like:var and a.dt_emprestimo between :var2 and :var3 and a.cod_cliente=b.cod_cliente order by a.dt_emprestimo´);
Params[0].Value := ´¬BMG¬´;
Params[1].Value := datetostr(comissao.dtini.Date);
Params[2].Value := datetostr(comissao.dtfin.Date);
Active := true;
open;
end;
Se alguem sabe como formatar a data do datapicker para aaaa/mm/dd eu agradeço.
[]´s
Danielle
Danielle Ballester
Curtir tópico
+ 0
Responder
Posts
11/03/2004
Rômulo Barros
...
Params[0].Value := ´¬BMG¬´;
Params[1].Value := FormatDateTime(´yyyy,mm,dd´,comissao.dtini.Date);
Params[2].Value := FormatDateTime(´yyyy,mm,dd´,comissao.dtfin.Date);
...
Params[0].Value := ´¬BMG¬´;
Params[1].Value := FormatDateTime(´yyyy,mm,dd´,comissao.dtini.Date);
Params[2].Value := FormatDateTime(´yyyy,mm,dd´,comissao.dtfin.Date);
...
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)