Focal Point
[SOLVED] Figuring the date minus 364 days

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

December 29, 2010, 03:39 PM
WendyC
[SOLVED] Figuring the date minus 364 days
I am using the following to get yesterday's date:

-SET &RPTDATE = &YYMD;
-SET &PRIORDAY = &RPTDATE - 1;
-*-SET &PREVYRDAY = &PRIORDAY - 364;
-TYPE &RPTDATE &PRIORDAY
-EXIT

and get the following result

20101229 20101228

now I need to get 364 days prior to the &PRIORDAY result. When I try the following code

-SET &RPTDATE = &YYMD;
-SET &PRIORDAY = &RPTDATE - 1;
-SET &PREVYRDAY = &PRIORDAY - 364;
-TYPE &RPTDATE &PRIORDAY &PREVYRDAY
-EXIT

I get the following results

20101229 20101228 20100864

which are obviously NOT what I want. The challenge for me is that the DATEADD function and the DAYMD function do not work for us with our current adapter version. Anyone have any suggestions? I am spinning my wheels at the moment.

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


WebFOCUS Dev Studio 7.6.11
Windows, all output
December 29, 2010, 04:02 PM
Waz
As you have discovered, adding and subtracting number from a date in dialog manager only takes the date as a number.

Have you tried AYMD ?

-SET &RPTDATE = &YYMD;
-SET &PRIORDAY = AYMD(&RPTDATE,-1,'I8YYMD') ;
-SET &PREVYRDAY = AYMD(&PRIORDAY,-365,'I8YYMD') ;
-TYPE &RPTDATE &PRIORDAY &PREVYRDAY
-EXIT


Check out the AYMD function in the documentation, under Legacy Date Functions.


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!

December 29, 2010, 04:07 PM
WendyC
Solved - that did it. I just couldn't come up with that. Must have looked at it too long this morning.
Thanks, all


WebFOCUS Dev Studio 7.6.11
Windows, all output
January 17, 2011, 05:46 PM
nsk110483
How to take care of the case where year is a leap year?

Please Help


In Focus since 2008
WebFOCUS 8.2.0.1
Windows 7 - IE,Chrome,Firefox
Excel, PDF, HTML, AHTML, XML
JavaScript, jQuery, D3.js, Highcharts
February 08, 2011, 08:53 AM
atturhari
How to find if a year is a leap year or not?

IS ther any WF function?

-Hari
WF-769


WF 7.7.02 on Windows 7
Teradata
HTML,PDF,EXCEL,AHTML
February 08, 2011, 11:49 AM
Tony A
Not specifically, but you can always grow your own if you just think about it a while -

DEFINE FUNCTION IS_LEAP(YEAR/I4)
  IS_LEAP/A1 = IF EDIT(YEAR,'$$99') EQ '00' AND (INT(YEAR / 400) * 400 NE YEAR) THEN 'N'
          ELSE IF (INT(YEAR / 4) * 4 EQ YEAR) THEN 'Y' ELSE 'N';
END
-RUN

-REPEAT :Loop FOR &Year FROM 1900 TO 2012;
-SET &LeapYear = IS_LEAP(&Year);
-TYPE &Year &LeapYear
-:Loop

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 
February 08, 2011, 07:15 PM
Doug
Nice Function Tony.

Full DM Solution:
-SET &YearToCheck = 2012 ;
-SET &IsItALeapyear = IF (INT(&YearToCheck / 4) * 4 EQ &YearToCheck) THEN 'Leap Year' ELSE 'Regular Year' ; 
-TYPE *** &YearToCheck is a &IsItALeapyear ***
-SET &YearToCheck as desired.
February 09, 2011, 09:22 AM
atturhari
Thanks a lot Tony and Doug. The code is simple and great.


WF 7.7.02 on Windows 7
Teradata
HTML,PDF,EXCEL,AHTML