Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
askarkhan
Contributor III
Contributor III

monthend in for next

Hi,

I want to use the last day of the month in STEP for "FOR NEXT" in script. How can I do that.

please see the code I am using and suggest.

LET vSTARTASKAR=43370; //MAKEDATE(YEAR(43370),MONTH(43370),DAY(43370));
LET vENDASKAR=TODAY()-1;

FOR  vOUTDATE = $(vSTARTASKAR) TO $(vENDASKAR) step MonthEnd(vSTARTASKAR)
OUTCALENDER:
LOAD
'$(vOUTDATE)' AS vOUTDATE,
63+$(vOUTDATE) as sum,
CD
Resident finalloop;
// EXIT FOR
NEXT

Labels (5)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

Try using å DO WHILE  loop in favour of the FOR loop.

Like this. 

LET vSTARTASKAR=43370;

Let vENDASKAR=TODAY()-1;

Do while  vSTARTASKAR < vENDASKAR

  OUTCALENDER:
  LOAD
    '$(vSTARTASKAR)' AS vOUTDATE,
    63+$(vSTARTASKAR) as sum,
    CD

  Resident finalloop;

  Let  vSTARTASKAR=floor(monthend(vSTARTASKAR, 1));

Loop

View solution in original post

2 Replies
Vegar
MVP
MVP

Try using å DO WHILE  loop in favour of the FOR loop.

Like this. 

LET vSTARTASKAR=43370;

Let vENDASKAR=TODAY()-1;

Do while  vSTARTASKAR < vENDASKAR

  OUTCALENDER:
  LOAD
    '$(vSTARTASKAR)' AS vOUTDATE,
    63+$(vSTARTASKAR) as sum,
    CD

  Resident finalloop;

  Let  vSTARTASKAR=floor(monthend(vSTARTASKAR, 1));

Loop

askarkhan
Contributor III
Contributor III
Author

thanks alot, This really helps.

I never thought of Do while.

 

This is working 100%