Focal Point
[SOLVED] today minus 1 day function in where clause.

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

April 08, 2013, 12:28 PM
kitten
[SOLVED] today minus 1 day function in where clause.
I'm trying to subtract 1 day from the current day and use it in a where clause. I'm confused on the format. The ENTDATE and DATE define fields work but I can't get the DAYAGO define to work. I also tried using the AYMD function. Can someone please assist.

DEFINE FILE INFO 
ENTDATE/HMDYY=ENTRYDATE
DATE/A10=TODAY(DATE);
DAYAGO/MDYY=DATEADD(DATE, 'D', -1);
END
TABLE FILE INFO
NAME
ADDRESS     
ENTDATE
WHERE ENTDATE EQ DAYAGO;

This message has been edited. Last edited by: kitten,


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
April 08, 2013, 12:40 PM
Doug
For starters, 1) add a semicolon at the end of this line: "ENTDATE/HMDYY=ENTRYDATE", 2) Add "DAYAGO" to your print line, 3) remove the WHERE statement, 4) Add a RECORDLIMIT and END, and see if "DAYAGO" is what you expect it to be, 5 take from there. and Smiler
April 08, 2013, 12:46 PM
kitten
Oops. I did have the semicolon at the end just didn't copy it over. I also tried to print the DAYAGO field but get the following error:
INVALID TYPE OF ARGUMENT #1 FOR USER FUNCTION DATEADD.

Should I have used the AYMD function?


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
April 08, 2013, 01:01 PM
Tom Flynn
Change DATE/A10=TODAY(DATE);
to
DATE/YYMD = '&DATEYYMD.EVAL';

The function requires a smart date...


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
April 08, 2013, 02:11 PM
kitten
quote:
DATE/YYMD = '&DATEYYMD.EVAL';


That worked Tom, but the where clause doesn't. I get the following error: (FOC280) COMPARISON BETWEEN COMPUTATIONAL AND ALPHA VALUES IS NOT ALLOWED
(FOC009) INCOMPLETE REQUEST STATEMENT

Do I need to convert the ENTDATE to Alpha?


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
April 08, 2013, 02:53 PM
Tom Flynn
Change:ENTDATE/HMDYY=ENTRYDATE;
To: ENTDATE/MDYY=ENTRYDATE;

For the WHERE test, need to have the same format; apples-to-apples, oranges-to-oranges, etc...


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
April 08, 2013, 03:35 PM
kitten
I can't change the ENTDATE to MDYY, because it has a date-time format when I remove the H it doesn't work.


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
April 08, 2013, 05:31 PM
nd
quote:
Originally posted by kitten:
I can't change the ENTDATE to MDYY, because it has a date-time format when I remove the H it doesn't work.


Use the HDATE function to get the datetime field into a simple date.

ENTDATE/MDYY=HDATE((ENTRYDATE,'MDYY');


WF: WebFocus 7.7.03
Data: Oracle, MSSQL, DB2
OS: Windows
Output: HTML/AHTML,PDF,EXL2K FORMULA, COMT
April 08, 2013, 06:18 PM
Alan B
Using a DEFINE for a screening condition is not efficient.

As an example, and I am using an HYYMDs field here, if you are using a different format change the expressions:
-SET &YESTERDAY    = AYMD(&YYMD,-1,'I8');
-SET &YESTERDAY    = EDIT(&YESTERDAY,'9999/99/99');
 TABLE FILE GENERATED
 PRINT *
 WHERE GENERATED_TIMESTAMP FROM DT(&YESTERDAY 00:00:00) TO DT(&YESTERDAY 23:59:59);
 END



Alan.
WF 7.705/8.007
April 09, 2013, 09:23 AM
kitten
Thanks Tom and ND it works. However I experimented with Alan's solution for efficiency and it also worked. Thanks Alan for the efficiency tip!!!


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML