Question

I have a problem with my SQL syntax. But I can not determine what is wrong with the syntax. The syntax is:

SELECT * FROM Inmuebles WHERE DATEDIFF(day, FechaIngreso, getdate()) <= 30

The reason why I put three parameters in the DATEDIFF function is because that I have read on here: DATEDIFF

The execution of this query has returned the following error:

#1582 - Incorrect parameter count in the call to native function 'DATEDIFF'

Then Google the mistake, and I came across the following post:

Error in calculating age in MySQL?

Having read this post, I decided to leave the query in this way:

SELECT * FROM Inmuebles WHERE DATEDIFF(FechaIngreso, getdate()) <= 30

But unfortunately tripped me with this error:

#1547 - Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted

Thanks for taking the time to read, please I hope you can forgive my horrible way to write English and can help with this problem. Greetings!

Was it helpful?

Solution

You're using MS SQL Server syntax:

GETDATE() = MS SQL Server

NOW()/CURDATE() = MySQL

If you want to DELETE the records returned from your query above it should just be:

DELETE FROM Inmuebles 
WHERE DATEDIFF(FechaIngreso, NOW()) <= 30;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top