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!

need to get the age

Status
Not open for further replies.

sonny1974

Technical User
Feb 25, 2007
161
US
im using sql server and crystal xi

i have a DOB field ex. 5/18/1947. i need to subract the DOB from today (would change daily by it self,not a hard coded today date).

just the age would be fine.

but if i can get example 60 and 9 months that would be better.
 
Here's Ken Hamady's (our local Crystal gurus) solution:


To get months, attack it a different way:

whileprintingrecords;
numbervar AllMonths:=datediff("m",{table.dob},currentdate);
numbervar MyYears:=int(AllMonths/12);
numbervar MyMonths:= remainder(allmonths,12);
"You're " & MyYears & " and going on " & MyMonths & " Old."

A bit of a cheat because of the subjective nature of determining the number of months. What is Feb 28th to Mar 30th? It wasn't over a month yet, but the days say so...

Anyway, one or both of these might work for you.

-k
 
im geeting 66.00 and 2.00 months. how would i take out the 0's
 
Try:

whileprintingrecords;
numbervar AllMonths:=datediff("m",{table.dob},currentdate);
numbervar MyYears:=int(AllMonths/12);
numbervar MyMonths:= remainder(allmonths,12);
"You're " & totext(MyYears,0,"") & " and going on " & totext(MyMonths+1,0,"") & " Old."

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top