MySQL 8: Incorrect datetime value: '$VARIANT$' for function str_to_date

154 Views Asked by At

I took over an old SQL query that includes the following expression:

SELECT 
g.Citystate,
g.Cityorder,
if(CityPostal is null, CityName, concat(CityName, ', ', CityPostal)) as CityName,
g.CityName as CityAdress,
g.CityKey,
@Published = ifnull(if (g.CityKey='S',
(SELECT sum(if(FROM_UNIXTIME(g1.Timestamp/1000) >= STR_TO_DATE('$VARIANT$', '%e.%m.%Y'), g1.Published, 0))
from PUBLISHED_DATA g1

If I execute the whole SQL Statement in DBeaver I get the following error: Incorrect datetime value: '$VARIANT$' for function str_to_date

I think the error occures because the syntax did not work with the newest MySQl version.

The query works if I pass a static string like "01.01.1971" as first argument to the STR_TO_DATE function. I'm searching for how to set up dynamic variable names, but I didn't find any solution. What does $VARIANT$ exactly mean? Does it define a parameter?

0

There are 0 best solutions below