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

AYMD problem

Status
Not open for further replies.

simaccs

Programmer
Jul 24, 2003
11
0
0
JP
Hello!

Anyone know why this return 0?
-* start
-SET &TYYMD = '20030803';
-SET &NDATE = AYMD(&TYYMD,150,'I8');
-TYPE '&NDATE'
-* end
in WEBFOCUS 4.3.5

thanx
via
 
My initial reaction to this is that the first -SET statement sets up a character string rather than an integer. I tried to duplicate the problem in MVS (I don't have access to WF) but it worked either with or without the quote marks.
Try it without the quote marks - maybe WF is more rigorous.
HTH
 
I got '20031231' in WF 5.2.1

Can anybody else reproduce the return value of 0?
 
I got the 20031231 also. Anyway, my MVS manual tells me that a 0 is returned by the subroutine when the input date is not valid; that is why I zeroed in (pardon the pun) on the first -SET statement.
 
Hi

-* start
-SET &TYYMD = '20030803';
-SET &NDATE = AYMD(&TYYMD,150,'I8');
-SET &NDATE2= AYMD(&TYYMD,149,'I8');
-SET &NDATE3= AYMD(&TYYMD,151,'I8');
-TYPE NDATE='&NDATE'
-TYPE NDATE2='&NDATE2'
-TYPE NDATE3='&NDATE3'
-* end

I can got without only '20031231'.

NDATE='0'
NDATE2='20031230'
NDATE3='20040101'

We must use WebFOCUS 5?

thanx a lot
 
Hi

thank you jimster but
-* start
-RUN
-SET &TYYMD = '20030803';
-RUN
-SET &NDATE = AYMD(&TYYMD,150,'I8');
-SET &NDATE2= AYMD(&TYYMD,149,'I8');
-SET &NDATE3= AYMD(&TYYMD,151,'I8');
-TYPE NDATE='&NDATE'
-TYPE NDATE2='&NDATE2'
-TYPE NDATE3='&NDATE3'
-* end

result----------------
NDATE='0'
NDATE2='20031230'
NDATE3='20040101'
----------------------

AYMD(indate,days,'I8')
any 'indate' and 'days' can not return '20031231'.

AYMD cannot return '20031231' in WF 4.3.5?

thanx again.
 
Below is copied out of the 4.3.5 manual.
Note the last argument.
Make that change and run it.
If there is still a problem, change the order of NDATE and NDATE2 and run. This should tell us if the problem is the format of TYYMD.
Begin Quote
AYMD: Adding or Subtracting Days to or From Dates
The AYMD subroutine takes a valid date in the form [YY]YYMMDD and adds or subtracts a given number of days from the submitted date.

AYMD only operates on dates in year-month-day format. You can convert a date to this format using the CHGDAT subroutine.


If the addition (or subtraction) of days crosses forward or back into a century, the century digits of the output year are adjusted.

For more information on AYMD, see the WebFOCUS Desktop online help or the Creating Reports manual.

Note: The last argument must be the name of the variable to which you are returning the result of the subroutine, not the format of the variable.
End quote. Emphasis mine
 
Hi jimster

Any change can not get '20031231'.

so we changed program.

-SET &NDATE = AYMD(&TYYMD,&ADATE,'I8');
-SET &NDATE = IF &NDATE EQ 0 THEN '20031231' ELSE &NDATE;

thanx all.
 
In case Webfocus 4.35 GE

put the following things in edasprof.prf

DEFINE FUNCTION AYMD(INDATE/I8,ADD/I8,FMT/A2)
D01/A3=DOWK(INDATE,'A3');
D02/I8=AYMD(INDATE,ADD,'I8');
D03/I8=IF (D01 NE ' ') AND (D02 EQ 0) THEN 20031231 ELSE D02;
D04/A8=EDIT(D03);
D05/A8=IF FMT EQ 'I6' THEN EDIT(D04,'$$999999')
ELSE IF FMT EQ 'I8' THEN D04 ELSE '0';
AYMD/I8=EDIT(D05);
END
 
You guys keep telling the subroutine to return an integer value. Note one example;

-SET &NDATE = AYMD(&TYYMD,&ADATE,'I8');

An I8 is not character, so what do you expect? If the subroutine can provide 'A8' output, take that. Otherwise, you will have to convert a returned integer value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top