I am trying to select only today\'s records from a database table.
Currently I use
SELECT * FROM `table` WHERE (`timestamp` > DATE_SUB(now(), INTE
Simply cast it to a date:
SELECT * FROM `table` WHERE CAST(`timestamp` TO DATE) == CAST(NOW() TO DATE)
SELECT * FROM `table` WHERE timestamp >= CURDATE()
it is shorter , there is no need to use 'AND timestamp < CURDATE() + INTERVAL 1 DAY'
because CURDATE() always return current day
MySQL CURDATE() Function
On Visual Studio 2017, using the built-in database for development I had problems with the current given solution, I had to change the code to make it work because it threw the error that DATE() was not a built in function.
Here is my solution:
where CAST(TimeCalled AS DATE) = CAST(GETDATE() AS DATE)