Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Check a date is in the current month

Posted on by Microsoft Employee

Hi,

How can I say IF recPurchaseLine."Expected Receipt Date" 'IS NOT IN THE CURRENT CALANDER MONTH' THEN 

ERROR();

*This post is locked for comments

  • Hannes Holst Profile Picture
    Hannes Holst 5,767 on at
    RE: Check a date is in the current month

    AlexDen: hehe, that's a new one for me :-)

  • AlexDen Profile Picture
    AlexDen 90 on at
    RE: Check a date is in the current month
    IF NOT (recPurchaseLine."Expected Receipt Date" IN [CALCDATE('<-CM>', TODAY)..CALCDATE('<CM>', TODAY)]) THEN
      ERROR('Incorrect date');

  • Murari Jangid Profile Picture
    Murari Jangid 77 on at
    RE: Check a date is in the current month

    Hello lewishhh,

    Try the below solution for your problem.

    Here FindDate_gDat is a Variable of type Date.

    IF DATE2DMY(FindDate_gDat,2) <> DATE2DMY(TODAY,2) THEN

     ERROR('Date is not of this month');

    Thanks

  • Hannes Holst Profile Picture
    Hannes Holst 5,767 on at
    RE: Check a date is in the current month

    I can think of two options.

    #1:

    IF (DATE2DMY(recPurchaseLine."Expected Receipt Date", 3) <> DATE2DMY(TODAY, 3)) OR
       (DATE2DMY(recPurchaseLine."Expected Receipt Date", 2) <> DATE2DMY(TODAY, 2))
    THEN
      ERROR('error message');

    #2:

    IF NOT ((CALCDATE('<-CM>', TODAY) <= recPurchaseLine."Expected Receipt Date") AND
            (CALCDATE('<CM>', TODAY) >= recPurchaseLine."Expected Receipt Date"))
    THEN
      ERROR('error message');


    Maybe working with the Date-Table offers a third option :-)

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans