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!

Future Date Calculating 1

Status
Not open for further replies.

RSedlacek

Programmer
Oct 5, 1998
59
US
I'm trying to use CF to calculate and output a future expiration date based on a current start date plus 1 month, 2 months, 3 months, etc. for a job listing site. Then I want to be able to disable a listing once this future expiration date has been reached.

I have been manually adding the expiration date and checking the listings that have expired and remove them daily. I know that it's probably pretty easily done in CF, but I have not been able to figure it out. The only thing I have been able to do is output the current date using...

#DateFormat(Now(),'ddd mmm dd, yyyy')#

Can anyone please assist me?
 
RSedlacek, you can use the 'dateadd' function in CF to create the future date, then use a CFIF statement to check if today's date is LTE to future_date. If the date is not, then disable the link.

A brief example:
Code:
<cfset today = dateformat(now(),'ddd mmm dd, yyyy')>
<cfset future_date = dateformat(dateadd('m',1,'#today#'),'ddd mmm dd, yyyy')>

<cfoutput>
  today is #today# <br/>
  future date is #future_date# <br/>
</cfoutput>
[/cdoe]

How come you don't let the user choose the expiration date when they originally post the job?  This would make life easy in that you can log the startdate and enddate and then run a simple CFIF to see if the currentdate is LTE to the enddate.

____________________________________
Just Imagine.
[URL unfurl="true"]http://www.imajinarts.com[/URL]
 
Thanks GUJUm0deL! This is exactly what I was looking for. Works like a charm. Hmmm...I wonder how charms work? :)

To answer your question..
The user decides how many months they want to run the listing. The expiration date is determined after the listing has been reviewed and the payment has been processed or received, so we can't allow the user to select the expiration date.

 
RSedlacek, glad I could have helped. LOL, I don't know how charms' taste, but I do know how Lucky Charms' taste...their magically delicous.

____________________________________
Just Imagine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top