Focal Point
Calculate number of months

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

January 25, 2008, 07:42 AM
FrankDutch
Calculate number of months
I want to calculate the number of months between a amper date (&YYMD) and a database date.

I tried this, but the result are wrong.

DATE is a field form the database

DEFINE FILE AH0124FA
PEREOM/YYMD=DATEMOV(DATE,'EOM'); 
TODAY/YYMD='&YYMD';
ACTEOM/YYMD=DATEMOV(TODAY,'EOM');
THISMAAND/YYM=TODAY;
MDIF/I5=DATEDIF(PEREOM,ACTEOM,'M');
END






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

January 25, 2008, 09:58 AM
Alan B
Frank

I've tried this and it seems fine. What is wrong with the results you are getting?


Alan.
WF 7.705/8.007
January 25, 2008, 10:01 AM
jimster06
Doesn't DATEDIF need four arguments: DATEDIF(from_date, to_date, 'unit', outfield) ?


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
January 25, 2008, 10:07 AM
Alan B
jimster06

Only for Maintain.


Alan.
WF 7.705/8.007
January 25, 2008, 11:17 AM
FrankDutch
Maybe it's fixed in 7.6
I get not the numbers I would expect, and in the book 1001 etc I found this as a know error .




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

January 25, 2008, 11:57 AM
mgrackin
Frank,

Did you verify that your input dates are what they should be?

Just a thought.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
January 25, 2008, 12:01 PM
Edward Wolfgram
Frank, it sounds like a simple subtraction should work for you- e.g.

-SET &YYM = EDIT(&YYMD,'999999') ; 
                                   
...                                
                                   
MYNEWM/YYM  = MYNEW ;              
MYYM/YYM WITH DVAL = '&YYM' ;      
MDIF/I5 = MYYM - MYNEWM ;          




IBI Development
January 25, 2008, 01:44 PM
FrankDutch
I'll give it a try (Monday), thanks for the suggestions.




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

January 25, 2008, 08:31 PM
N.Selph
The system date, &YYMD is not in smart date YYMD format.
It is in I8YYMD format. You have to convert it to a smart date with DATECVT before you can use it in a smart date function like DATEMOV.

PEREOM/YYMD=DATEMOV(DATE,'EOM'); 
TODAY/YYMD=DATECVT(&YYMD,'I8YYMD','YYMD');
ACTEOM/YYMD=DATEMOV(TODAY,'EOM');



(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
January 26, 2008, 10:56 AM
susannah
           
WHAT/YYMD   =  &YYMD  ;      

now actually seems to work.
it seems its gotten easier to make a smartdate out of an integer string.
in 764 anyway.
zowie, batman.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
January 28, 2008, 09:54 AM
jgelona
I've been doing this for 20 years:
CURRDT/YYMD=&YYMD;

Even back in regular FOCUS it has always worked (at least in PC, VAX and UNIX it has).

When I want months between 2 dates I do this:
CURRDT/YYMD=&YYMD;
DIFFMTH/I4=DATEDIF(DATE,CURRDT,'M');

I've never seen anytime this didn't work.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.