problemas com manipulacao de datas
Ola pessoal to com o seguinte problema.. Nao consigo receber nenhum retorno em um select que faz a busca de alunos inadimplentes durante um certo periodo de tempo. A minha string eh a seguinte:
[b:04ea0f07d3]
Select * From Mensalidade
WHERE situacao = ´A´ and Venc Between :dtini and :dtfim
ORder by Venc
[/b:04ea0f07d3]
e veja a implementacao do onclick do botao:
[b:04ea0f07d3]
procedure TGeraRelAluPen.BitBtn1Click(Sender: TObject);
begin
QGEraPen.Close; //ADOQuery
QGeraPen.Parameters[0].value := formatdatetime(´dd/mm/yyyy´, de.Date);
QGeraPen.Parameters[1].value := formatdatetime(´dd/mm/yyyy´, ate.Date);
ShowMessage(QGeraPen.Parameters[0].value);
ShowMessage(QGeraPen.Parameters[1].value);
ShowMessage(QgeraPen.SQL.Text);
QgeraPen.open;
close;
AlunosPen.preview; //RELATORIO
end;
[/b:04ea0f07d3]
No 3o. ShowMessage, a string SQL eh mostrada sem os valores dos parametros, e isso impede que o meu relatorio retorne valores na tela, enquanto o 1o e 2o showmessage, mostra os valores do parametro.
Lembrando que estou usando um ADO para acessar ACCESS e para pegar as datas um TDateTimePicker
Valeu para quem puder ajudar!
=)
[b:04ea0f07d3]
Select * From Mensalidade
WHERE situacao = ´A´ and Venc Between :dtini and :dtfim
ORder by Venc
[/b:04ea0f07d3]
e veja a implementacao do onclick do botao:
[b:04ea0f07d3]
procedure TGeraRelAluPen.BitBtn1Click(Sender: TObject);
begin
QGEraPen.Close; //ADOQuery
QGeraPen.Parameters[0].value := formatdatetime(´dd/mm/yyyy´, de.Date);
QGeraPen.Parameters[1].value := formatdatetime(´dd/mm/yyyy´, ate.Date);
ShowMessage(QGeraPen.Parameters[0].value);
ShowMessage(QGeraPen.Parameters[1].value);
ShowMessage(QgeraPen.SQL.Text);
QgeraPen.open;
close;
AlunosPen.preview; //RELATORIO
end;
[/b:04ea0f07d3]
No 3o. ShowMessage, a string SQL eh mostrada sem os valores dos parametros, e isso impede que o meu relatorio retorne valores na tela, enquanto o 1o e 2o showmessage, mostra os valores do parametro.
Lembrando que estou usando um ADO para acessar ACCESS e para pegar as datas um TDateTimePicker
Valeu para quem puder ajudar!
=)
Thales
Curtidas 0
Respostas
Bruno_fantin
16/11/2004
Não use FormatDateTime.... Passa a data como TDateTime mesmo...
GOSTEI 0
Bruno Belchior
16/11/2004
tenta isso:
begin with QGEraPen do begin Close; //ADOQuery Parameters.ParamByName(´dtini´).Value:= DateToStr(de.Date); Parameters.ParamByName(´dtfim´).Value:= DateToStr(ate.Date); ShowMessage(Parameters.ParamByName(´dtini´).Value); ShowMessage(Parameters.ParamByName(´dtfim´).Value); ShowMessage(SQL.Text); Open; end; Close; AlunosPen.preview; //RELATORIO end;
GOSTEI 0
Thales
16/11/2004
Rodou, porem mesma coisa, nao retorna nada..
GOSTEI 0
Bruno Belchior
16/11/2004
quando vc esta salvando vc usa o FormatDateTime?
GOSTEI 0
Otto
16/11/2004
aqui uso assim:
Select * From Mensalidade WHERE situacao = ´A´ and Data_Nascimento >= ´2000/10/10´ and Data_Nascimento <= ´2002/10/10´
GOSTEI 0
Adilsond
16/11/2004
Deixe que o componente se preocupe com a formatação do campo data.
procedure TGeraRelAluPen.BitBtn1Click(Sender: TObject); begin with QGEraPen do begin if Active then Close; //ADOQuery Parameters[0].AsDateTime := de.Date; Parameters[1].AsDateTime := ate.Date; Open; try if IsEmpty then raise Exception.Create(´Não existem informações a serem impressas no período informado.´); AlunosPen.preview; //RELATORIO finally Close; end; end; end;
GOSTEI 0