0

Hi,

I have a list of about 100 pages, each of them using date_create variable for the date they were entered in the database; these entries are from years 2005 to 2008. I need to list the ones from the last six months only, but without hardcoding specific values, so it automatically outputs the correct list. Could somebody help me modifying the code to accomplish this?

The code I'm using as of now is:

<cfquery name="disp_news_arti_curr" datasource="#Request.MainDSN#" CACHEDWITHIN="#CreateTimeSpan(1,0,0,0)#">
SELECT 
id_news_arti,url,name_pub,date_create,author_pub,title
FROM 
data_news_arti
WHERE
status = 1 AND date_create >= '01 Sep 2005'
ORDER BY
date_create DESC
</cfquery>

Thanks
<snipped>

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by cmhampton
0
<cfquery name="disp_news_arti_curr" datasource="#Request.MainDSN#" CACHEDWITHIN="#CreateTimeSpan(1,0,0,0)#">
SELECT 
           id_news_arti,
           url,
           name_pub,
           date_create,
           author_pub,
           title
FROM 
           data_news_arti
WHERE
           status = 1 
           AND date_create >= DateAdd(m, -6, getDate())
ORDER BY
           date_create DESC
</cfquery>

This will return any article less than 6 months old. Here's more info on the DateAdd function:

http://doc.ddart.net/mssql/sql70/da-db_5.htm

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.