Page 1 of 1

CAST Bug

Posted: Sat 10 Mar 2018 04:19
by Aggie85
Howdy Maxim!

I found another issue with TVirtualQuery.

If you have a TDateTime field in a source dataset and issue a SQL statement as follows:

SELECT CAST(DateTimeField AS DATE) AS SomeFieldName FROM SourceDataSet

No matter what the TDateTime date value is, the date is always returned as October 7, 1905.

I have emailed you a test app demoing the issue.

All the best,

Aggie85

Re: CAST Bug

Posted: Wed 14 Mar 2018 13:13
by MaximG
Obviously, this issue is not related to the error in VirtualQuery, but it occurs due to the work specificity of the SQLite DBMS, on the basis of which the SQL engine is built in VirtualDAC. When defining the field types of the query result, SQLite for the CAST expression (DateTimeField AS DATE) returns the INTEGER type. As a result, the date value, which is initially stored in TkbmMemTable in a field of DATETIME type is read as INTEGER, and then converted to TDateTime when displayed in TDateTimeField. This is the result of the wrong displayed value. Unfortunately, we cannot affect the behavior of SQLite in this situation in any way.

Re: CAST Bug

Posted: Wed 14 Mar 2018 15:20
by Aggie85
Howdy Maxim!

I was actually thinking that yesterday and I haven't GOOGLED it yet. I can fix it in the data set but I will see if I can find a SQLLITE solution later today.

Thanks for all the help.

Aggie85

Re: CAST Bug

Posted: Wed 14 Mar 2018 15:49
by Aggie85
Howdy All!

IF anyone else ever runs into this issue, see the SQLITE 'strftime' method!

All the best,

Aggie85

Re: CAST Bug

Posted: Fri 16 Mar 2018 08:36
by MaximG
We are glad that you found a necessary solution. You are right, you can use the SQLite-function "strftime()" to solve the described task. Please contact us on any questions regarding the use of our product