SBX - Search With Button

SBX - Forum Post Title

Loop

Microsoft Dynamics NAV Forum

jsshivalik asked a question on 15 May 2018 11:58 AM
My Badges

Question Status

Verified

Hi

   I want to loop from start date to end date. How I can add 1 to start date till it is equal to end date

Thanks

Reply
RockWith NAV responded on 15 May 2018 12:29 PM
My Badges
Suggested Answer

Rec.RESET;

Rec.SETRANGE(Date,StartDate,EndDate);

IF Rec.FINDSET THEN

REPEAT

//Loop

UNTIL Rec.Next = 0;

Reply
jsshivalik responded on 15 May 2018 11:37 PM
My Badges

Hi

   I want to add 1Day to Start Date till it becomes equal to End Date . In this case i don't want to use Setrange.

Thanks

Reply
Chris D'silva responded on 16 May 2018 3:35 AM
My Badges
Verified Answer

Hi,

StartDate:=CALCDATE('< +1D >',TODAY); //here I'm adding 1 day to Today's date.

REPEAT

//ur code

UNTILL startdate=ENDdate

Reply
jsshivalik responded on 16 May 2018 5:37 AM
My Badges

Hi Chris

  There is one issue . If EndDate = 11/03/2018 . Start Date = 01/03/2018. When i loop according to the above Code it display Data only till 10/03/2018. Since at this Stage Start Date becomes equal to EndDate then it should not go in Repeat Loop which i think so.

Thanks

Reply
Olister Rumao responded on 16 May 2018 10:47 PM
My Badges

Hi jsshivalik,

Put the code

StartDate:=CALCDATE('< +1D >',TODAY);

inside the REPEAT UNTIL loop.

Reply
Chris D'silva responded on 16 May 2018 3:35 AM
My Badges
Verified Answer

Hi,

StartDate:=CALCDATE('< +1D >',TODAY); //here I'm adding 1 day to Today's date.

REPEAT

//ur code

UNTILL startdate=ENDdate

Reply
RockWith NAV responded on 15 May 2018 12:29 PM
My Badges
Suggested Answer

Rec.RESET;

Rec.SETRANGE(Date,StartDate,EndDate);

IF Rec.FINDSET THEN

REPEAT

//Loop

UNTIL Rec.Next = 0;

Reply

SBX - Two Col Forum

SBX - Migrated JS