Page 1 of 1

Tokenizer EConvertError - DateTime

Posted: 12.09.2011, 13:06
by thcom
hi, i am using Delphi 7 lite on Windows 7 with MySQL 5.1.41

when i use SQL statement like this DATE_FORMAT(test,"%H:%i:%s") AS test

i get error EConvertError in IDE, in runtime is it OK

i try to debug this strange thing, and i found ZGenericSqlToken.pas

there is a method TZGenericSQLQuoteState.NextToken, which decodes part of SQL which contains two semicolons as a date, but in my case it is "%H:%i:%s" string decoded as a date and the conversion produces this error

can u help me, with this strange behaviour ??

i attach D7 example with sql dump
but enough is open a query whch contains DATE_FORMAT with format string containing 2 semicolons

thx Tomas, Prague

Posted: 12.09.2011, 21:52
by seawolf
Hi, at the moment I can't test, but Can you try changing DateSeparator to - and TimeSeparator to : (on ZGenericSqlToken.pas) ?

If it works correctly the problem is related to the way ZMySQLToken.pas set those functions

Posted: 29.09.2011, 13:02
by thcom
hi, sorry for late answer, i try to change date and time separator, i use 'x' character, because we in czech republic use ':' as time separator and '.' as date separator.

my application is now working properly, but i have strange feeling ...
should i leave this hack in zeos source ?

thank you Tomas

Posted: 08.10.2011, 21:16
by mdaems
What about changing the tokenizer so that it only interprete strings containing double '/' and/or double ':' as date/time when there are no other characters than numbers and spaces involved? Maybe that won't cover all valid date/time strings? But changing the rule to 'only 0 or 2 numbers allowed between // and ::' would already be a much stronger test than we have now.

Do you feel like making this work?

Please post your changes to TZGenericSQLQuoteState.NextToken here so we can add this to the zeoslib source code.

Mark