Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Convert funcion not working

M3MB3R's profile image M3MB3R posted 1 month ago in Running SQL scripts Permalink

I would to use CONVERT() in a task to convert an AVG() of timedates back to timedate format, but I tried to use the function even in HeidiSQL or phpmyadmin, it's just gives me a syntax error.

Even if I copy there something as simple like this: SELECT CONVERT(int, 25.65); It causes syntax error.

I checked on the official site of MariaDB and it should work this way, but doesn't. :(

ansgar's profile image ansgar posted 1 month ago Permalink

The documentation says expression comes first and then the type, not the other way around. So this works:

SELECT CONVERT(25.65, int);
M3MB3R's profile image M3MB3R posted 1 month ago Permalink

I substitued it with CAST and found out that it can't do a real conversion to TIME or DATE, TIME(200) won't be 00:03:20 but 00:02:00. I tought it manages the integer as 'seconds', or, with DATE, DATE(x) handles x as days, but I was naive. :D

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.