Page 1 of 1

SQLite and timestamp

Posted: Fri 08 Feb 2013 00:26
by JHerrera
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.

Re: SQLite and timestamp

Posted: Fri 08 Feb 2013 11:31
by AlexP
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 + '%''');

Re: SQLite and timestamp

Posted: Fri 08 Feb 2013 15:04
by JHerrera
Alex, thank you, the query is running ok now.

Re: SQLite and timestamp

Posted: Mon 11 Feb 2013 12:22
by AlexP
Hello,

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