SQLite and timestamp

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JHerrera
Posts: 2
Joined: Thu 07 Feb 2013 23:45

SQLite and timestamp

Post by JHerrera » Fri 08 Feb 2013 00:26

Hi. I'm using Delphi 7, UniDac 4.6.11 and Sqlite provider.

I have in my database a field with timestamp and I'm not getting decode this field. All registers has this field starting with YYYY-MM and my query get the records from a specific year and month. The query works with SQL server but not with Unidac. My question is: what is the best way to get all records that starting with YYYY-MM? I tried compare with a variable string and % but no success.

The string to be used is created with:
if ComboBox1.ItemIndex < 10 then
begin
strIndice := '0'+IntToStr(ComboBox1.ItemIndex)
end
else
begin
strIndice := IntToStr(ComboBox1.ItemIndex)
end;
strSelect := combobox2.text + '-' +strIndice;

I'd like use strselect% in the query. Any idea?

Thanks in advance.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: SQLite and timestamp

Post by AlexP » Fri 08 Feb 2013 11:31

hello,

If you use a TIMESTAMP field, you can add a comparison to the WHERE section in the following way:

Code: Select all

  UniQuery1.AddWhere('field_name like + ''' + strselect + '%''');

JHerrera
Posts: 2
Joined: Thu 07 Feb 2013 23:45

Re: SQLite and timestamp

Post by JHerrera » Fri 08 Feb 2013 15:04

Alex, thank you, the query is running ok now.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: SQLite and timestamp

Post by AlexP » Mon 11 Feb 2013 12:22

Hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.

Post Reply