Search code examples
mysqlsqldategetdate

how to select reservations of today in sql for wordpress


What am I doing wrong here?
I'm trying to select reservations of today but it results in nothing.

SET @date = 'GETDATE(YYYY-MM-DD)';
SELECT * FROM `database`.`table`
WHERE (CONVERT(`meta_value` USING utf8) LIKE '%"@date"%');

Solution

  • You could try this if you are using MYSQL database

    SELECT * FROM database.table WHERE database.table.Date_Column = CURRENT_DATE;

    Or

    For SQL Server you could do this

    SELECT * FROM database.table WHERE database.table.Date_Column = CONVERT(date, GETDATE());

    Hope this would help you!