954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

...today's date plus 1 year?


#DateFormat(Now(), "mmm-dd-yyyy")#

the result is:

Jul-09-2009

What i wanted to do is....to add 1 year from todays date or
I want to show a date that is a year after. Is thare a cf tag that will help me do that? is that possible? Do i need to use a language outside coldfusion?

tiny7415
Light Poster
25 posts since Mar 2010
Reputation Points: 10
Solved Threads: 1
 
arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 
<cfset yearAhead = DateAdd( "yyyy", 1, Now() ) />

<cfset dateFormatted = DateFormat( yearAhead, "mmm-dd-yyyy" ) />

<cfoutput>
#dateFormatted#
</cfoutput>
samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

I didn't think the documentation was that cryptic. But then I'm more of a "teach a man to fish ..." kind of person ;)

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

Thanks Samaru! , and Arrgh!

I thought I did the right thing in updating the date to 1 year ahead. What I did was instead of DateFormat code, I did the TimeFormat code.

Both of you helped me a lot. I am now doing my personal web. It's nothing in there yet but hopefully when i come up with a good idea on what to put there, i will let you both look at it.

I would be happy to get your feedback once you see my coldfusion website.

tiny7415
Light Poster
25 posts since Mar 2010
Reputation Points: 10
Solved Threads: 1
 
I thought I did the right thing in updating the date to 1 year ahead. What I did was instead of DateFormat code, I did the TimeFormat code.

I'm not sure what you mean. Neither of those functions perform date math. They only format values for output. Also, TimeFormat() is used for formatting time values, not dates.

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

Well, the first code that i used was timeFormat. this code gave me the wrong result which gave me an idea to start this thread.

then you gave me a link that led me to a site and found out that the code that i used was for the time. if i want to add 1 year to my date then i have to use the dateformat.

then samaru posted a code that confirmed my thought. so i would just like to thank you.

tiny7415
Light Poster
25 posts since Mar 2010
Reputation Points: 10
Solved Threads: 1
 

Ah, ok. But just to keep things straight, the DateAdd() function is what's actually adding 1 year to your date. DateFormat() doesn't do anything but make the value pretty ;)

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

yep,
DateFormat(DateAdd(yyyy, 1, date))

Thanks to all of you!!!!

tiny7415
Light Poster
25 posts since Mar 2010
Reputation Points: 10
Solved Threads: 1
 

arrgh, Don't let us catch you asking for code on any forum. We'll just send you directly to the documentation. if someone asks for help and code, just give it to them.

paulbaylis1
Newbie Poster
1 post since Oct 2010
Reputation Points: 7
Solved Threads: 0
 

paulbaylis1

You seem to need a few lessons in learning how to communicate with others. Every one else here managed to remain civil, and take the comments in friendly manner in which they were intended. Except you. While you can certainly express your opinions, you can't tell other people what to do. One would hope your coding skills are not as limited as your social skills appear to be. If not, I don't think you'll have to worry about anyone asking for your advice.

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You