Topic: Changing an age on a particular day

i-Dave    -- 10-04-2002 @ 1:43 PM
  I have been playing with the following code:

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

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

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

Pablo can you Help?

(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
  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:


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?

Pablo Varando

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

i-Dave    -- 10-05-2002 @ 3:41 AM
  Smile  Thats perfect Pablo, Thank you!

Webmaster    -- 10-05-2002 @ 11:51 AM
  No problem Smile

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

Till next time...

Pablo Varando

EasyCFM.COM ColdFusion Forums :