Focal Point
Help with DATEDIF

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5051069272

February 22, 2008, 02:26 PM
newtofocus
Help with DATEDIF
I need help from WebFOCUS gurus out there. I am trying to get the difference between two dates using DATEDIFF but gett wrong result. Here is the code that I am using.

-SET &XDATE_FRM_YYMM='&DATE_FRM_YY.EVAL'|'&XDATE_FRM_MM.EVAL';
-SET &AYM1 = EDIT(&XDATE_FRM_YYMM,'999999');
-SET &DATE_FROM=AYM(&AYM1,'-1','I6');

-SET &MON_BEG_DATE = EDIT(&DATE_FROM,'999999') | '01';
-
-SET &DATE_TO ='&DATE_TO_YY.EVAL'|'&XDATE_TO_MM.EVAL';
-SET &MON_END_DATE = EDIT(&DATE_TO,'999999') | '31';
-SET &MONTH_DIFF = DATEDIF(&MON_BEG_DATE,&MON_END_DATE,'M');

When my month begining date is 20071001 and end date is 20080131, I am getting the difference as 299.

Thanks.


WF7.1.4 Prod/Test, MRE, self serve, DM
February 22, 2008, 05:32 PM
FrankDutch
I would ad some debug lines to your code to evaluate the intermediate results.

Start with

-SET &ECHO=ALL;

then at the end I would do some type commands

If you put in the last line

-SET &MONTH_DIFF=DATEDIF(20071001,20080131,'M');

What is the result? what you expect (4) than this line is ok. And so on.

Did you buy the book "Almost 1001 ...."




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 23, 2008, 01:34 PM
Danny-SRL
Hi,
Your problem is that DATEDIF works with FOCUS dates and not with LEGACY dates (which is what one has in Dialog Manager). Try the following:
-SET &MON_BEG_DATE ='200701';
-SET &MON_END_DATE = '200801';
-SET &MONTH_DIFF = YM(&MON_BEG_DATE,&MON_END_DATE,'I3');
-TYPE &MONTH_DIFF &MON_BEG_DATE &MON_END_DATE



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF