Tuesday, December 11, 2012
Function GetAgeDetailFull in Crystal Report
สร้าง custom function ชื่อ GetAgeDetailFull
Function (dateTimeVar p_BirthDay , dateTimeVar p_ApplyDay)
numberVar IntervalMonth ;
numberVar IntervalDay ;
numberVar ISTodayAfter ;
dateTimeVar BirthDay := p_BirthDay;
dateTimeVar ApplyDay := p_ApplyDay;
stringvar ReturnAge ;
IntervalDay := DATEDIFF('d', BirthDay, ApplyDay);
IntervalMonth := DATEDIFF("m", BirthDay, ApplyDay);
if(DATEDIFF('d', DATEADD('y', DATEDIFF('y', BirthDay, ApplyDay), BirthDay), ApplyDay) > 0) then
ISTodayAfter := -1
else
ISTodayAfter := 0 ;
if( IntervalDay < 0 ) THEN
ReturnAge := ''
else if((DATEDIFF('y', BirthDay, ApplyDay)+ISTodayAfter) > -1 ) THEN
ReturnAge := totext(DATEDIFF('yyyy', BirthDay, ApplyDay)+ISTodayAfter,"##0")+'Y '+
totext(datepart('m',datetime(tonumber(DATEDIFF('d',BirthDay , ApplyDay ))))-1,"#0")+'M '+
totext(datepart('d',datetime(tonumber(DATEDIFF('d',BirthDay , ApplyDay ))))-1,"#0")+'D ';
ReturnAge;
วิธีเรียก function GetAgeDetailFull({FieldName},CurrentDate);
Labels:
Crystal Reports
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment