Delete line according to date difference in Mysql

Asked

Viewed 27 times

0

I am trying to delete lines from a table using as a reference the difference between the current date and the date the line was registered. Here is my code:

 DELETE FROM lixeira
 WHERE diferenca > 60 IN
 (
 SELECT DATEDIFF('2018-11-20',data_exclusao) AS diferenca
 FROM lixeira
 ) 

Since "data_deletion" is the column that stores the registration date of the row data. However, the console is returning me the following error:

Mensagem de erro

  • 1

    Why don’t you call datediff right in the where? Something like where datediff(...) > 60

  • I tried, but I wasn’t erasing the lines of agreement I wanted, I’ll try again.

  • Also confirm the function parameters in the documentation, the type of return and the type of columns involved.

  • It worked, apparently it was because the column "data_exclusion" was DATETIME, I switched to DATE and it worked, thanks for the warning.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.