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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports 8.5 first day of year function

Status
Not open for further replies.
May 21, 2001
52
US
I am trying to figure out how to do a datediff calculation using a persons birthdate and first day of the year. I do not want to hardcode 01/01/2006. If I hardcoded I would have to update the report formula every year. This is what I have so far:

numbervar Age:= DateDiff("YYYY",{PS_PERSON.BIRTHDATE} , CurrentDate);

I have tried doing some different things with current date by using the year function and trying to concatenate 01/01/ but so far no luck. Any suggestions?

Thanks, Richard
 
Got it figured out:

numbervar firstday:= 01;
numbervar firstmonth:= 01;
numbervar currentyear:= year(CurrentDate);
datevar begofyear:= CDate(currentyear,firstmonth,firstday);

numbervar Age:= DateDiff("YYYY",{PS_PERSON.BIRTHDATE} , begofyear);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top