Skip to content
Advertisement

DATEADD in MariaDB

I’m using DATEADD statement in SQL Server and I need migration to MariaDB

And i got error like this

[42000][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 ‘varchar, Production.MadeDate , 112) BETWEEN DATE_ADD(DAY, -2, ‘2018-06-05’) AND ‘ at line 3

I’m got references from MariaDB DATE_ADD and MariaDB ADDDATE but it’s still doesn’t working

My Version MariaDB 10.1.32-MariaDB

EDIT :

[SOLVED]

Changing the SQL Statment from CONVERT to CAST

TO

It’s working for me on

Advertisement

Answer

You can’t use the CONVERT like this on MariaDB / MySQL:

The order of the parameters isn’t valid on MariaDB / MySQL. The order of the parameters looks like TSQL / SQL Server syntax.

So you can replace the current CONVERT with one of the following:

You can use the following SUM using CAST and DATE_ADD:

Note: Check the condition on CASE WHEN also. You check between the same days.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement