![]() |
HJB 3/13/2025 |
... for inspiration purposes only ... P.S. Seen code mentions "7" for a week, so for only one day, you would need to adjust to "!" |
A
|
anthonywalker author 3/13/2025 |
Thanks for the reply cooper21! Ive tested your recomendation but I cant seem to get the results?
For example im using date=13/03/2025 in the WHERE clause but it says No results found in the list.. As you can see all the entires ive done are today and are showing in the list:
Any idea what im doing wrong? Thanks |
C
|
Chris Whitehead 3/14/2025 |
This is just how I'd try find out why. I'm wondering how you are storing the date, as using 13/03/2025 as a condition won't work, dates are stored in the tables usually as 2025-03-13, that's if your datatype is set to DATE and not DATETIME. if it's set to varchar then trying to perform any date related functions will fail such as reformatting or adding/subtracting days. Using NOW() returns a timestamp rather than todays date so gives you 2025-03-14 05:05:37 which won't match the date due to the time, so you may have to use greater than or equal to in the condition.">=". your_date_field >= DATE_FORMAT(NOW(), '%Y-%m-%d') You could also use your_date_field > DATE_SUB(NOW(), INTERVAL 1 DAY) which would set the date as yesterday and give you the records with todays date. If you could put up a screenshot of your table fields with the settings that might help. maybe even a shot of the table with the data. |
A
|
anthonywalker author 3/14/2025 |
Hi Chris, Thanks for replying. Ive tried both of your suggestions to no avail. Below are some of the screenshots you requested:
Thanks |
A
|
anthonywalker author 3/14/2025 |
Ive also checked the database and the date is showing as: 2025-03-13T00:00:00.0000000 |
A
|
anthonywalker author 3/14/2025 |
Im getting the following error when using the now()
|
A
|
anthonywalker author 3/14/2025 |
Hi All, I have figured it out, the query I needed was: CAST(date AS DATE) = CAST(GETDATE() AS DATE) Thanks all! |
C
|
Chris Whitehead 3/14/2025 |
Glad you've got it sorted. |