Muirik
Muirik

Reputation: 6289

What is the Issue with this Convert() in this SQL Query Against MariaDB

I am converting some SQL statements now that we're running against MariaDB instead of SQL Anywhere. In one of the queries, I'm getting an error on this line:

select convert(char, c.dob, 1) as "DOB"

Specifically, this is the error that is produced:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'c.dob, 1) as "DOB",

My understanding is that this "convert" is trying to produce a value of type "char" from the "dob" value, which is currently of type date.

What would the issue be in this case? Does it have to do with the way MariaDB handles dates differently?

Upvotes: 0

Views: 86

Answers (1)

Rick James
Rick James

Reputation: 142296

CONVERT() has only 2 arguments:

https://mariadb.com/kb/en/library/convert/

And the datatype is second.

Furthermore, if c.dob is any type of date or time, then you do not need any conversion function. It will automatically produce a string in that context.

Upvotes: 1

Related Questions