Jump to content
Fórum Script Brasil
  • 0

[resolvido] Consulta De Data


Pirambu!
 Share

Question

Alguém sabe como eu posso realizar uma consulta de uma determinada data e entre dois periodo usando a mesma query?

eu já tentei assim

with query1 do
begin
close;
sql.clear;
sql.add('select * from tabela1 where data1 between :A and :B');
parambyname('A')asdate := DateTimePicker1.date;
parambyname('B')asdate := DateTimePicker2.date;
open;
end;
o problema e se eu consultar o mesmo dia dá erro. eu também tentei assim, mas não aparece a data que eu consulto:
with query1 do
begin
close;
sql.clear;
sql.add('select * from tabela1 where data1 >= :A and data1 <:B');
parambyname('A')asdate := DateTimePicker1.date;
parambyname('B')asdate := DateTimePicker2.date;
open;
end;

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
Guest --Jonas --

teste desta maneira:

with query1 do
begin
close;
sql.clear;
sql.add('select * from tabela1 where data1 >= :A and data1 <= :B'); // modificação
parambyname('A')asdate := DateTimePicker1.date;
parambyname('B')asdate := DateTimePicker2.date;
open;
end;

Link to comment
Share on other sites

  • 0

Voce pode também utilizar o between:

with query1 do
begin
  close;
  sql.clear;
  sql.add('select * from tabela1 where data1 between :A and :B');
  parambyname('A')asdate := DateTimePicker1.date;
  parambyname('B')asdate := DateTimePicker2.date;
  open;
end;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...