Focal Point
[SOLVED] 2nd Friday of the every Month

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

January 30, 2013, 03:00 AM
kumar27
[SOLVED] 2nd Friday of the every Month
Hi waz

Based on this code i'm trying to find out Second Friday of the Month

i'm getting Second Friday of the Month corretly for all the months a expect "June" month not correct

Could you please give me solution for this

DEFINE FUNCTION SCNDSAT/A8YYMD (SEEDDATE/A8YYMD)
SEEDYYMD/YYMD = SEEDDATE ;
CALC1/YYMD = DATEMOV(SEEDYYMD, 'BOM') ;
DOW/W = CALC1 ;
FIX/I1 = IF DOW EQ 7 THEN 7 ELSE 0 ;
CALC2/YYMD = CALC1 + (6 - DOW) + 7 + FIX ;
SCNDSAT/A8YYMD = CALC2;
END

-RUN

-SET &TESTDATE = '20130601' ;
-SET &RES = SCNDSAT(&TESTDATE) ;

-TYPE &TESTDATE - &RES



Thanks
kumar

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


WebFOCUS 7.6
Windows, All Outputs
January 30, 2013, 10:06 AM
eric.woerle
try using EOW instead of the calculation you have. It should simplify things.

DEFINE FUNCTION SCNDSAT/A8YYMD (SEEDDATE/A8YYMD)
SEEDYYMD/YYMD = SEEDDATE ;
CALC1/YYMD = DATEMOV(SEEDYYMD, 'BOM') ;
YYMDEOW/YYMD=DATEMOV(CALC1, 'EOW')  ;
CALC2/YYMD=YYMDEOW + 7;
SCNDSAT/A8YYMD = CALC2;
END

  

For me EOW gives me Friday.

If you wanted to, you could also condense the calculation into one line
CALC1/YYMD = DATEMOV(DATEMOV(SEEDYYMD, 'BOM') ,'EOW') +7


Thanks


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
January 30, 2013, 03:42 PM
Waz
Changing the FIX line should do it.

FIX/I1 = IF DOW EQ 7 THEN 7 ELSE IF SEEDYYMD EQ CALC1 THEN 6 ELSE 0 ;


But I do like Eric's suggestion. even if the EOW moves to Saturday or Sunday, the calc is quite easy.


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!

January 30, 2013, 09:35 PM
kumar27
Thanks waz for providing solution


WebFOCUS 7.6
Windows, All Outputs
January 31, 2013, 02:17 PM
FrankDutch
Elegant function which might be even better if you add 2 extra variables so you can also get the 3th Wednesday or the 4th Monday .
Or what about the last business day of the month.
(We have reports that need to be executed via reportcaster at the 4th business day of the month, something that would be a great improvement of the reportcaster schedule function)




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 07, 2013, 05:09 AM
kumar27
Hi

with this code how to find 2nd sunday of the every Month

i'm new to webfocus

could you plese help me

quote:
Originally posted by eric.woerle:
try using EOW instead of the calculation you have. It should simplify things.

DEFINE FUNCTION SCNDSAT/A8YYMD (SEEDDATE/A8YYMD)
SEEDYYMD/YYMD = SEEDDATE ;
CALC1/YYMD = DATEMOV(SEEDYYMD, 'BOM') ;
YYMDEOW/YYMD=DATEMOV(CALC1, 'EOW')  ;
CALC2/YYMD=YYMDEOW + 7;
SCNDSAT/A8YYMD = CALC2;
END

  

For me EOW gives me Friday.

If you wanted to, you could also condense the calculation into one line
CALC1/YYMD = DATEMOV(DATEMOV(SEEDYYMD, 'BOM') ,'EOW') +7


Thanks



WebFOCUS 7.6
Windows, All Outputs
February 08, 2013, 12:05 PM
eric.woerle
Kumar,

In example 1, you want to adjust Calc2 to add or subtract the number of days between the day you are trying to find and the first friday of the month. In this case you are looking for the second sunday so that would 9 (sunday is 2 days after friday, and you want one week later)


quote:
Originally posted by kumar27:
DEFINE FUNCTION SCNDSAT/A8YYMD (SEEDDATE/A8YYMD)
SEEDYYMD/YYMD = SEEDDATE ;
CALC1/YYMD = DATEMOV(SEEDYYMD, 'BOM') ;
YYMDEOW/YYMD=DATEMOV(CALC1, 'EOW')  ;
CALC2/YYMD=YYMDEOW + 7;
SCNDSAT/A8YYMD = CALC2;
END

  


In example 2 you would do the same thing, only you adjust calc 1 by 9.

quote:
CALC1/YYMD = DATEMOV(DATEMOV(SEEDYYMD, 'BOM') ,'EOW') +7


Thanks


If this still doesn't make sense, try stepping through the logic. I find that breaking things apart helps me understand things better

Eric


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
February 10, 2013, 02:44 PM
susannah
Frank, what you need can be accomplished with a preprocessing condition, a fex that decides if today is the 4th bd, and sets KILl_RPC to Y if its not. then schedule the job for the 4,5,6,7th of every month. not so elegant, but works. i do it that way.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
February 11, 2013, 06:30 PM
FrankDutch
Yes susannah, that is how I do it..but the kill of rc gives me an error message and i want to avoid that.
The same issue comes in datamigrator .

I have a small proces that runs on the first day of the month five minutes after midnight.
It makes a list of the working day numbers skipping weekend and holidays. Now I can easy pick the 4th or 11th workday of the month, but still need to run that process several days a month.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7