We have an audit that logs quite a bit of stuff, but we need to create something that does a clean up after 5 days. For some reason the DEFINE FILE FILELIST below isn't adding the new column. Anyone see something wrong with the following code that would prevent NEWDATE from showing up?
-SET &THENDTTM = DATEADD(&YYMD, 'D', -5);
-SET &THENDTTM = EDIT(&THENDTTM,'9999') | '/' | EDIT(&THENDTTM,'$$$$99') | '/' | EDIT(&THENDTTM,'$$$$$$99');
-TYPE THENDTTM = &THENDTTM
APP QUERY audit_logger HOLD
-RUN
TABLEF FILE FOCAPPQ
PRINT
DATE
TIME
FILENAME
ON TABLE HOLD AS FILELIST
END
-RUN
DEFINE FILE FILELIST
NEWDATE/YYMD = DATE;
END
-RUN
TABLE FILE FILELIST
PRINT *
-*WHERE NEWDATE LT '&THENDTTM';
END
This message has been edited. Last edited by: GavinL,
- FOCUS Man, just FOCUS! ----------------------------- Product: WebFOCUS Version: 8.1.04 Server: Windows 2008 Server
April 06, 2016, 05:01 PM
jfr99
Use ...
PRINT * NEWDATE instead of ...
PRINT *
WebFocus 8.201M, Windows, App Studio
April 07, 2016, 09:30 AM
GavinL
Thanks, I figured that out, but I come to the conclusion I must be overthinking this process, because it's kicking my @$$. I can have this written in 2 minutes within .NET, but using FOCUS, it's been 2 days.
- FOCUS Man, just FOCUS! ----------------------------- Product: WebFOCUS Version: 8.1.04 Server: Windows 2008 Server
April 07, 2016, 11:02 AM
GavinL
Date conversions are an absolute nightmare in WebFocus. That really needs to be worked on.
How exactly does
DATEADD(&YMD, 'D', -10)
Result in:
160397
Looks like it convert it to an int and just subtracted 10 from it, unless there is 97 days in March all of a sudden.
Help clearly gives an example with use of string date.
Example: Using the Weekday Unit
If you use the weekday unit and a Saturday or Sunday is the input date, DATEADD changes the input date to Monday. The function
DATEADD('910623', 'WD', 1)
(FOC281) ALPHA ARGUMENTS IN PLACE WHERE NUMERIC ARE CALLED FOR
Kind of throws out the help that states:
Syntax: How to Add or Subtract a Date Unit to or From a Date
DATEADD(date, 'component', increment)
where:
date
Date
Is a full component date.
- FOCUS Man, just FOCUS! ----------------------------- Product: WebFOCUS Version: 8.1.04 Server: Windows 2008 Server
April 08, 2016, 03:30 AM
Tony A
quote:
Is a full component date.
Gavin,
This is the important piece, a full component date. Not a partial representation such as &YMD but a full date representation as in &YYMD.
Folks have always had trouble in getting date conversion / addition / movement functions to work and it is usually down to a misunderstanding of what the documentation states. Whether that calls for a legacy date, full component date etc.
Once it clicks then ......
Good luck
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10
April 08, 2016, 09:58 AM
GavinL
I was using &YYMD first and I get the same results. It subtracts 10 as a number, not a date. I've figured it out though.. I'll post it as Sharing.
- FOCUS Man, just FOCUS! ----------------------------- Product: WebFOCUS Version: 8.1.04 Server: Windows 2008 Server