PDA

View Full Version : Date Query?


scooby
04-28-2004, 11:03 PM
How can I retrieve information from an access database where the date is today or in the coming 7 days.
My table = Fixtures, with a field for DATE, and a field for TEAM.

I use very basic SQL SELECT scripts like that below

<% sqlString = "SELECT * FROM FIXTURES ORDER BY DATE DESC"
SET RS = oConn.Execute(sqlString)
WHILE NOT RS.EOF
%>
<%=RS( "date")%>
<%=RS( "team")%>

Any ideas??

Thanks

Roy Sinclair
04-28-2004, 11:18 PM
SELECT * FROM FIXTURES ORDER BY [DATE] DESC
WHERE DATEDIFF(Day, GetDate(),[Date]) In (0,1,2,3,4,5,6,7)

That's how I'd do it with SQL Server, Access should work similarly if not identically.

glenngv
04-29-2004, 04:26 AM
This is how I'd do it:

SELECT * FROM FIXTURES WHERE [DATE] BETWEEN Date() AND Date()+7 ORDER BY [DATE] DESC

or

SELECT * FROM FIXTURES WHERE DateDiff('d', Date(), [DATE])>=0 AND DateDiff('d', Date(), [DATE])<=7 ORDER BY [DATE] DESC

I prefer the first one.

scooby
04-29-2004, 11:18 PM
This is the most suitable and best answer return yet. I have searched all over the net and other forums just tell me to either use MYSQL or PHP and have never given me a proper reply.

Thanks Guys

M@rco
05-03-2004, 11:34 PM
Glenn's first option gets my vote. :thumbsup: