Buy Now
Sign in

Use Current Date in Where Condition

vividal , February 02 at 14:28
Answered
V
vividal

I have a field (game_start - datetime type) in my table that stores the Date & Time. I want to show all records with today's date, regardless of the time. If I hard code the date and time as below I get the events that start at that time but not the others.

game_start/=:2018-02-02 19:00:00

What I am really looking for is the function/syntax to get all events for "TODAY", regardless of the time but can't seem to figure it out as I have tried a bunch of variations of date(), datetime(), now(), etc.

E
emmexx

Have you tried the following?​

game_start:{date:Y-m-d}​

bye

maxx

V
vividal

I had not but that still didnt work as it created

`Schedule`.`game_start` = '2018-02-02'

which returns no results BUT it the syntax was helpful and I have implented ​

game_start/>=:{date:Y-m-d 00:00:00}
game_start/<=:{date:Y-m-d 23:59:59}

which produces the desires results.

thank you.