As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
I would like to be able to work out a person's name while taking into account the leap years.
Dividing by 365.25 is not accurate enough for what I want to do as its quite sensitive. I've also tried to do a datediff but thats not accurate enough.
I have searched for previous posts but non of them have what I need.
PS: I can do this quite easily in MS SQL. See code below :
SELECT DATEDIFF(YY, @BirthDate, @CurrentDate) - CASE WHEN( (MONTH(@BirthDate)*100 + DAY(@BirthDate)) > (MONTH(@CurrentDate)*100 + DAY(@CurrentDate)) ) THEN 1 ELSE 0 END AS AGEThis message has been edited. Last edited by: Kerry,
WebFOCUS 7.7.3 PMF 5.3.1, Windows, Mainly HTML..eventually XLS, PDF AHTML.
You can do the same of course in webfocus. Extract all the same portions from the dates involved and do the same logic. It will look a little bit different from how it looks in MS SQL, but the logic is the same and it will give you the same result.
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
Ok, here goes. This is assuming you have the birthdate as a YYMD field. If not, you'll have to do some conversion.
DEFINE FILE xxxx
-*Extract years
CDYY/YY = &DATEYY;
BDYY/YY = BIRTHDATE;
-* Compute difference
YEARS/I4 = CDYY - BDYY;
-* Extract month/day
CDMD/I8 = &MDYY / 10000;
HELP/A8YYMD = BIRTHDATE;
BDMD/I8 = EDIT(EDIT(HELP,'$$$$9999'));
-* See if a year must be subtracted
SUBYEAR/I4 = IF BDMD GT CDMD THEN 1 ELSE 0;
-* Compute age
AGE/I4 = YEARS - SUBYEAR;
END
TABLE FILE xxxx
PRINT BIRTHDATE AGE
END
Hope this helps ...
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
I must be missing something here. DATEDIF works quite well I find, leap years included.
DEFINE FILE CAR
-*TODAY/DMYY = '&DATEDMYY';
TODAY/DMYY = '28/02/1997';
PAST/YYMD = '1996/02/29';
YRS/I2 = DATEDIF(PAST,TODAY,'Y');
MTH/I2 = DATEDIF(DATEADD(PAST,'Y',YRS),TODAY,'M');
DAY/I2 = DATEDIF(DATEADD(PAST,'M',(YRS*12)+MTH),TODAY,'D');
END
TABLE FILE CAR
PRINT YRS AS 'Year(s)'
MTH AS 'Month(s)'
DAY AS 'Day(s)'
BY HIGHEST 1 COUNTRY NOPRINT
END
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
Yea, not really a leap year issue. Looks like it was more about not counting the current year in the age until you have your birthday in the current year. Looks like GamP nailed it.
WebFOCUS 8.2.06
Posts: 210 | Location: Sterling Heights, Michigan | Registered: October 19, 2010
...and that is what DATEDIF does. It looks at the complete dates, not just the yeaar portion, and provides the correct number of years, as in the correct age of a person.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
DEFINE FILE xxxx -*Extract years CDYY/YY = &DATEYY; BDYY/YY = BIRTHDATE; -* Compute difference YEARS/I4 = CDYY - BDYY; -* Extract month/day CDMD/I8 = &MDYY / 10000; HELP/A8YYMD = BIRTHDATE; BDMD/I8 = EDIT(EDIT(HELP,'$$$$9999')); -* See if a year must be subtracted SUBYEAR/I4 = IF BDMD GT CDMD THEN 1 ELSE 0; -* Compute age AGE/I4 = YEARS - SUBYEAR; END TABLE FILE xxxx PRINT BIRTHDATE AGE END
it does work in a procedure but when i call the procedure in HTML it gives me the following error
FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: CDYY
FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: CDMD
FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: YEARS
Do we need to declare variables? or what is missing. because it does work if i run the procedure indiviually.
So, let me get this straight -- at no point did anyone in IB-land consider returning the result as a real number so you could just truncate the pig? This is a crazy level of effort to figure out how old somebody is.This message has been edited. Last edited by: John_Edwards,
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007