Forums
This topic is locked
Filtering records by date
Posted 11 Aug 2006 20:31:20
1
has voted
11 Aug 2006 20:31:20 Bob Marshall posted:
HiI have an ASP dynamic page which retrieves a list of diary dates from a MySQL database.
I want to be able to display on the ASP page only the dates which have not yest passed. For example: today, tomorrow and every day after's date should show, but not yesterday's.
Does anyone know how to code this as an SQL statement? I have tried using the date function in the statement: <b>WHERE diaryDate>=Date()</b> but this doesn't seem to work. Am I doing this right?
Any help greatly appreciated.
Edited by - Arcturus on 11 Aug 2006 20:43:22
Replies
Replied 11 Aug 2006 21:48:25
11 Aug 2006 21:48:25 Barry Clark replied:
As far as I know, for MySQL it should be:
WHERE diaryDate >= CURDATE()
Barry
WHERE diaryDate >= CURDATE()
Barry
Replied 11 Aug 2006 21:50:24
11 Aug 2006 21:50:24 Barry Clark replied:
Replied 12 Aug 2006 11:58:42
12 Aug 2006 11:58:42 Bob Marshall replied:
Thanks for the advice.
I have found that the following works great for me.
select * FROM diary WHERE diaryDate >= DATE_SUB(curdate(), INTERVAL 1 DAY)
I have found that the following works great for me.
select * FROM diary WHERE diaryDate >= DATE_SUB(curdate(), INTERVAL 1 DAY)