Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

check if dates are consecutive

Posted on by 1,392

hi,

Please how to achieve this using C/al

How to check if these dates are consecutive

30/12/2017

31/12/2017

01/01/2018

02/01/2018

03/01/2018

and how to check if these dates aren't consecutive

04/01/2018

06/01/2018

07/01/2018

Best regards

*This post is locked for comments

  • ManishS Profile Picture
    ManishS 6,578 on at
    RE: check if dates are consecutive

    Why do you want to check the date consecutive ?

    Any specific need ? Can you please share the detail.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: check if dates are consecutive

    Choose the temp table which has integer as key, and store the dates in both tables , sort one by date and when you loop through that record, inside repeat try to get the second record which the same entry no. if they both don't match it means they are not consecutive.

    Of if you know they are very limited then you could do the same using dimension with an array.

  • MedInfoTech Profile Picture
    MedInfoTech 1,392 on at
    RE: check if dates are consecutive

    Hello,

    thank you for your replies,  i'm agree this is the logic but i don't know compare what with what ?!!

    Rec.setcurrentkey(key);

    Rec.setfilter(Rec.rec1,'=%1',Rec.rec1::test);

    IF Rec.FindSet

    Repeat

      IF  ??????????

    Until Rec.next = 0;

  • Suggested answer
    Alexander Ermakov Profile Picture
    Alexander Ermakov 28,094 on at
    RE: check if dates are consecutive

    Sort it and then compare the duration between each nearest; if result would be >1 day, then they aren't consecutive.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: check if dates are consecutive

    Store in the a temporary date table and sort it by Date and compare it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans