3 Replies Latest reply on Nov 14, 2019 10:36 PM by Ilyas Shaikh

# Need to set a variable to end of week Friday

I need to pass as PARM1 the end of the week Friday's date in the following format:

\$PARM1=YYYYMMDD ----------------------(week ending Friday date)

How do I calculate the Friday's date if the job runs, let's say, on a Monday?

• ###### 1. Re: Need to set a variable to end of week Friday

If your job is running on a set date then you just use %%\$CALCDATE to add the required number of days.

Otherwise, I'm thinking to use %%OWDAY. Depending on when your start day of week is will determine whether this works.

If my start day of week is Saturday, then %%OWDAY for Saturday is 0, Sunday is 1, Friday is 6.

To determine how many days prior to Friday we are running do:
%%DAYGAP = 6 %%MINUS %%OWDAY

So if the job is scheduled on Monday (2), the gap is 4.

Then use

%%FRIDAY_DATE = %%\$CALCDATE %%\$ODATE +%%DAYGAP

Something like that. I haven't tested this code.

Hope this helps, it might not work depending on your start day of week, or maybe someone has a simpler idea!

Cheers,

Paul.

3 of 3 people found this helpful
• ###### 2. Re: Need to set a variable to end of week Friday

Thank you, Paul. I will give this a try.

• ###### 3. Re: Need to set a variable to end of week Friday

Hi Stacy,

If the job is scheduled on Monday, you can use following to get the Friday date:

FRIDAY_DATE=%%\$CALCDATE %%DATE -3

Regards,

Ilyas Shaikh

1 of 1 people found this helpful