Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for only showing data in a certain date interval 2

Status
Not open for further replies.

movium

Technical User
Feb 18, 2002
14
SE
Hi,

This is my QUERY today:

<CFQUERY NAME=&quot;Aktuellt&quot; DATASOURCE=&quot;movium&quot;>
SELECT * FROM UTBILDNING WHERE DATE_UTBILDNING < #DateAdd('D', 90, Now())#
ORDER BY DATE_UTBILDNING
</CFQUERY>

The query is supposed to pick courses that has todays date and 90 days forward. Strangely, older courses than Now () are also showing. What am I doing wrong here?

Regards

Niclas Östlund
 
You could also try:

<CFQUERY NAME=&quot;Aktuellt&quot; DATASOURCE=&quot;movium&quot;>
SELECT * FROM UTBILDNING
WHERE DATE_UTBILDNING >= #CreateODBCDate(Now())#
AND DATE_UTBILDNING < #CreateODBCDate(DateAdd(&quot;d&quot;, 90, Now()))#
ORDER BY DATE_UTBILDNING
</CFQUERY> - tleish
 
It's not strange; your query asks for all dates less than (older) than 90 days from today. Naturally, you will get dates older than Now(). Try this:

CFQUERY NAME=&quot;Aktuellt&quot; DATASOURCE=&quot;movium&quot;>
SELECT *
FROM UTBILDNING
WHERE DATE_UTBILDNING between #CreateODBCDate(Now())#
AND #CreateODBCDate(DateAdd(&quot;d&quot;, 90, Now()))#
ORDER BY DATE_UTBILDNING
</CFQUERY>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top