SBX - Search With Button

SBX - Forum Post Title

Check a date is in the current month

Microsoft Dynamics NAV Forum

Lewishhh asked a question on 13 Sep 2018 9:37 AM
My Badges

Question Status

Unanswered

Hi,

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

ERROR();

Reply
Hannes Holst responded on 13 Sep 2018 10:13 AM
My Badges

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 :-)

Reply
Murari Jangid responded on 14 Sep 2018 12:28 AM

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

Reply
AlexDen responded on 14 Sep 2018 4:13 AM
My Badges
IF NOT (recPurchaseLine."Expected Receipt Date" IN [CALCDATE('<-CM>', TODAY)..CALCDATE('<CM>', TODAY)]) THEN
  ERROR('Incorrect date');

Reply
Hannes Holst responded on 14 Sep 2018 4:56 AM
My Badges

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

Reply

SBX - Two Col Forum

SBX - Migrated JS