Focal Point
Solved -- Yesterday's Date and same date last year

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

March 01, 2012, 10:29 AM
Spence
Solved -- Yesterday's Date and same date last year
I can get yesterday's date:
-SET &TODAY = &YYMD;
-SET &YDAY = AYMD (&TODAY, -1, 'I8YYMD');

How do I get the same date last year when there was no 20110229, I was subtracting 1 from the current year and using the month and day.

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


WF 8 version 8.2.04. Windows.
In focus since 1990.
March 01, 2012, 10:39 AM
Wep5622
What would be the correct date for that rule? As you say, yesterday's date a year ago, or 20100229, does not exist.

Would that be 20100301 (365 days ago) or 20100228 (the nearest day in the same month)?


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
March 01, 2012, 10:43 AM
Tewy
This subtracts one year from the date, and for the 29/02/2012 results in 28/02/2011.

LASTYEAR/YYMD=DATEADD(DATE_YYMD, 'Y', -1);


WF 7.6.11
Output: HTML, PDF, Excel
March 01, 2012, 10:49 AM
Spence
Tewy, Can this be done in Dialogue Manager?
LASTYEAR/YYMD=DATEADD(DATE_YYMD, 'Y', -1);


WF 8 version 8.2.04. Windows.
In focus since 1990.
March 01, 2012, 10:59 AM
Tewy
Yes, you need to do the following:

-SET &lastYear= DATECVT(DATEADD(DATECVT(&YYMD,'I8YYMD','YYMD'),'Y','-1'),'YYMD','I8YYMD');


WF 7.6.11
Output: HTML, PDF, Excel
March 01, 2012, 11:14 AM
Spence
Tewy - That did it. Thank you.

-SET &TODAY = &YYMD;
-SET &YDAY = AYMD (&TODAY, -1, 'I8YYMD');
-SET &lyday = DATECVT(DATEADD(DATECVT(&YDAY,'I8YYMD','YYMD'),'Y','-1'),'YYMD','I8YYMD');

-TYPE &|YDAY == &YDAY
-TYPE &|lyday == &lyday
-EXIT


WF 8 version 8.2.04. Windows.
In focus since 1990.
March 02, 2012, 09:11 AM
jgelona
Want to use DATEADD in DM, this works and in less confusing that DATECVT/DATEADD/DATECVT method.

Create the following DEFINE FUNCTION and -INCLUDE it in the edasprof

-*
-*  Use this function to use DATEADD in Dialogue Manager
-*
 DEFINE FUNCTION UDATEADD(INDATE/A8YYMD, INUNIT/A2, INNBR/I4)
   INDATE1/YYMD    = INDATE;
   UDATEADD1/YYMD  = DATEADD(INDATE1, INUNIT, INNBR);
   UDATEADD/A8YYMD = UDATEADD1;
 END
-RUN


Then in DM do this:

-SET &LASTYEAR=UDATEADD(&YYMD,'Y',-1);


I have DEFINE FUCTIONS for DATEADD, DATEMOV and DATEDIF.

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


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
March 02, 2012, 11:42 AM
njsden
Good point, jgelona. Sticking DATECVT back and forth before any DATE computation in Dialogue Manager is usually a point of confusion to many, and a hard one to spot errors in when used in long expressions.

I like the idea of your user-defined functions and most importantly the fact that you kept the same "signature" as that of the original WebFOCUS ones ... definitely much easier to use.

Good One



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.