Focal Point
DATEADD but in Focus Variable?

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

October 28, 2013, 11:30 AM
cs_source
DATEADD but in Focus Variable?
Hi, So i have been searching for a thread to help me out but i believe the code i'm finding works in Dialogue Manager but not in focus code when creating a variable via a procedure?

What i'm trying to do is get the max date of a column from a table and substract 1 month. i have it corrected pulling the latest date however i can't seem to get it to substract 1 month?

Here is my code so far:

-SET &DDDATE=;

DEFINE FILE DAD
WRKD/A8YYMD=Discharge_Date;
WRKDA/A10=EDIT(WRKD,'9999/99/99');
-*WRKDAY=DATEADD(WRKDA,'M', -7); <- I believe this is the correct place to take the date which i have captured and just go back 1 month?
END


TABLE FILE DAD
SUM MAX.WRKDA
ON TABLE HOLD AS WD FORMAT ALPHA
END
-RUN

-READ WD &DDDATE.A10.

-RUN

-SET &&DDDATE='&DDDATE.EVAL';
&&DDDATE

Any help would be greatly appreciated thank you!


WebFocus 8.02, SQL Server 2008r2
October 28, 2013, 04:31 PM
Waz
What is the format of Discharge_Date ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 29, 2013, 06:22 AM
Twanette
Hi,

As per the WebFOCUS "Using Functions" manual:
quote:

DATEADD requires a date to be in date format. Since Dialogue Manager interprets a date as alphanumeric or numeric, and DATEADD requires a standard date stored as an offset from the base date, do not use DATEADD with Dialogue Manager unless you first convert the variable used as the input date to an offset from the base date.


So, as per the example:
TABLE FILE EMPLOYEE
PRINT FIRST_NAME HIRE_DATE 
COMPUTE NEW_DATE/YYMD = HIRE_DATE;
COMPUTE HIRE_DATE_PLUS_THREE/YYMD = DATEADD(NEW_DATE, 'WD', 3);
BY LAST_NAME
END


Your "in" date needs to be e.g. YYMD format.
And the "out" date (WRKDAY) needs a format.

So, if Discharge_Date is already a YYMD format, you probably need something like this:

  WRKDAY/YYMD=DATEADD(Discharge_Date,'M', -7); 



WebFOCUS 8.2.06 mostly Windows Server
October 30, 2013, 07:57 AM
linus
Use AYMD() for &VARs (Dialogue Manager)

  
-SET &DAY15 = AYMD(&YYMD, -15, 'I8');



WF 7.7.05
HP-UX - Reporting Server, Windows 2008 - Client, MSSQL 2008, FOCUS Databases, Flat Files
HTML, Excel, PDF
October 30, 2013, 09:55 AM
jgelona
Need to use DATEADD, DATEMOV and DATEDIF in Dialogue Manager?

Use DEFINE FUNCTION

Check out my post here:

Using DATE Functions in DM


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
October 30, 2013, 12:25 PM
cs_source
quote:
Discharge

Hi Waz,

Discharge date is in 'YYYY-MM-DD'

thank you guys the only thing is Dialogue manager (in webfocus) is not the same as a procedure (in data migrator? uses focus langauge?) i'm trying to do this for a flow so i set a global variable so it can be used later on in the flow

example

where Discharge_Date = %%DDDATE

maybe i'm mixing the two up?


WebFocus 8.02, SQL Server 2008r2