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>

<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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.