Código
1) convertendo o campo do access para string no formato "yyyymmdd"
sIni := QuotedStr(FormatDateTime('yyyymmdd', dtIni));
sFim := QuotedStr(FormatDateTime('yyyymmdd', dtFim));
sSql := 'Select * from movimento where '+
' (format(DT_LANC,''yyyymmdd'') >= '+sIni+
' and format(DT_LANC,''yyyymmdd'') <= '+sFim+') ';
ADOQuery1.SQL.Text := sSql;
ADOQuery1.Open;
2) comparando o valor do MÊS e ANO da data.
sMes := FormatDateTime('mm', dtIni);
sAno := FormatDateTime('yyyy', dtFim);
sSql := 'Select * from movimento where '+
' ( Month([DT_LANC]) = '+sMes+
' and Year([DT_LANC]) = '+sAno+') ';
ADOQuery1.SQL.Text := sSql;
ADOQuery1.Open;
Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009