EasyCFM.COM ColdFusion Forums / Coding Help! / Changing an age on a particular day

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Changing an age on a particular day

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

i-Dave
10-04-2002 @ 1:43 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 10
Joined: Oct 2002

I have been playing with the following code:

cfset one = #dateformat(now(), "yyyy")#

cfset age = #DateDiff("y", "1978", "#one#")#
cfoutput#age#/cfoutput

But I want the age to change on the 16th of February of each year.

Pablo can you Help?

Dave
(I removed the <> cos i dont know how to get cf code to appear in the forum!!!!)

This message was edited by i-Dave on 10-4-02 @ 1:45 PM

Webmaster
10-04-2002 @ 3:41 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

If I unsertand you correctly, you want to display a person's age as it they were born on February 16th, 1978 and you want to show their age, is that correct?

If it is, here's the easier way to achieve what you're looking to do.

First create a variable that will be February 16th, 1978. (You can also pass this from a DB, etc).

You can do this as follows:
<!--- first set the date of birth --->
<cfset DOB = #CreateDate("1978", "02", "16")#>

Then get the age of the individual as follows:

<!--- get this person's age --->
<cfset age = #DateDiff("yyyy", DOB, NOW())#>

Now display the age:

<cfoutput>#Age#</cfoutput>


That's is the easiest way to achieve what you are looking to do. (Of course if I understood your question correctly! Smile  )

That code will change the agent on February 16,th of every year!

Is this what you wanted?



Thanks,
Pablo Varando
EasyCFM.COM, LLC.

This message was edited by Webmaster on 10-5-02 @ 4:57 PM

i-Dave
10-05-2002 @ 3:41 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 10
Joined: Oct 2002

Smile  Thats perfect Pablo, Thank you!

Webmaster
10-05-2002 @ 11:51 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

No problem Smile

Let me know if I can help you in any other way!

Till next time...

Thanks,
Pablo Varando
EasyCFM.COM, LLC.


Website Designed and Developed by Pablo Varando.