Search values between two dates in Sqlite

Asked

Viewed 535 times

0

How can I find the records on two dates in the bank Sqlite?

In mysql I know it is through BETWEEN, but I don’t know how you do it in Sqlite.

  • In the Sqlite is BETWEEN https://www.sqlite.org/lang_expr.html

2 answers

1

Sqlite uses BETWEEN as stated in the comment, follow example:

Sqlfiddle - Online example:

SELECT * FROM Pessoa WHERE Data BETWEEN '2000-01-01' AND '2015-01-01'

Note: If you tried with BETWEEN and failed the problem may be in date format, Sqlite expects the date to be in a format YYYY-MM-DD, may be that he is treating his search as string.

Source: https://stackoverflow.com/a/8187379/7558069

-3

Just put . Asdate := Strtodate(Ndata); the date may be in DD/MM/YY itself. Follows code:

Dms.Qsq4.Close;

Dms.Qsq4.SQL.Clear; Dms.Qsq4.SQL.Add(Sql);

Dms.Qsq4.Parambyname('DATAINI'). Asdate := Strtodate(Ndataini);

Dms.Qsq4.Parambyname('DATAFIN'). Asdate := Strtodate(Ndatafin);

Dms.Qsq4.Open;

Dms.Qsq4.first;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.