October 28, 2013, 11:30 AM
cs_sourceDATEADD 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!
October 28, 2013, 04:31 PM
WazWhat is the format of Discharge_Date ?
October 29, 2013, 06:22 AM
TwanetteHi,
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);
October 30, 2013, 07:57 AM
linusUse AYMD() for &VARs (Dialogue Manager)
-SET &DAY15 = AYMD(&YYMD, -15, 'I8');
October 30, 2013, 09:55 AM
jgelonaNeed to use DATEADD, DATEMOV and DATEDIF in Dialogue Manager?
Use DEFINE FUNCTION
Check out my post here:
Using DATE Functions in DMOctober 30, 2013, 12:25 PM
cs_sourcequote:
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?