Actually
 
here is a little function I knocked up for you
 
<cfscript>
 function getAge(dob)
  {
  if (dob CONTAINS "-")
   {delim = "-";}
  else if (dob CONTAINS "\")
   {delim = "\";}
  else if (dob CONTAINS "/")
   {delim = "/";}
  else if (dob CONTAINS " ")
   {delim = " ";}
  else
   {delim = "noDelim";}
  if (delim EQ "noDelim")
   {age = "Not a date";}
  else
   {age = DateDiff("yyyy",CreateODBCDateTime(ListSetAt(dob,2,MonthAsString(ListGetAt(dob,2,delim)),delim)),NOW());}
  return age;
  }
</cfscript>
 
<cfset myAge = getAge("22-12-1975")>
<cfoutput>#myAge#</cfoutput>
 
The key is to convert the month into a string so when you convert it to an ODBC date, it knows which value is the month

Regards

Steve Onnis
Domain Concept Designs
+61 422 337 685
+61 3 9431 4249

http://www.domainconceptdesigns.com
[EMAIL PROTECTED]
http://www.cfcentral.com.au
[EMAIL PROTECTED]

("If you think it can't be done, you haven't asked me!") - Steve Onnis

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 1:26 PM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Date difference and create date and date format AGE today

Thank you Steve
 
the problem i have is my format is 31/12/2003 and is called from the database as #DOB#
 
can you point me in the right direction so the date diff works with format 31/12/2003 = DOB
 
#DateDiff("yyyy",CreateODBCDateTime("DOB"),NOW())#
 
regards and thank you
greg stone
----- Original Message -----
Sent: Tuesday, March 18, 2003 1:01 PM
Subject: [cfaussie] RE: Date difference and create date and date format AGE today

#DateDiff("yyyy",CreateODBCDateTime("1975-12-22"),NOW())#
 

Regards

Steve Onnis
Domain Concept Designs
+61 422 337 685
+61 3 9431 4249

http://www.domainconceptdesigns.com
[EMAIL PROTECTED]
http://www.cfcentral.com.au
[EMAIL PROTECTED]

("If you think it can't be done, you haven't asked me!") - Steve Onnis

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 12:53 PM
To: CFAussie Mailing List
Subject: [cfaussie] Date difference and create date and date format AGE today

Hi
 
i have a DOB date format 31/12/2003 and want to calculate the age today.
 
my current attemp to get this  working is below  but i can't switch the date format to match my stored info (DOB)
 
I cant work out how to combine the date format and the date create
#DateFormat(1960,06,10, "dd/mm/yyyy")#
 
here is my current attempt
<cfscript>
yearssgone = DateDiff("yyyy",CreateDate(1960,06,10),NOW());
</cfscript>
<strong>age today :<cfoutput>#yearssgone#</cfoutput></strong>
 
Can any one help with this one.
maybe a simpler snippet
 
thanks inadvance
greg stone
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/ ---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to