How to add days to a date to obtain a date

Flashtn
Member Posts: 68
Hi Dear Navision Developers,
I want to compare a date1 to other date2 in this manner:
Thank you in advance
I want to compare a date1 to other date2 in this manner:
IF date1 < date2 + 30D //adding 30 days to date2 ... ENDHow can I do this and to to add days to a date to obtain a date ?
Thank you in advance

0
Comments
-
IF date1 < (date2 + 30)
FYI if your using this in payables or receivables or inv, etc etc.
I would add a field in the appropriate setup table that holds the value of 30. So it can be changeable on the fly if needed.
example/
Say this is about some item start date or something.
add a field to the inv setup table Like Adjust Days
your code would be something like
InvSetup.GET;
If Date1 < (Date2+ Invsetup."Adjust Days").....0 -
Thank you for your response
But, is not accepted in this codition, an error message appear that indicates that's impossible to evaluate this condition :
Date AND Integer !!!0 -
hmm works for me - are you sure date1 & date2 are date fields?
perhaps you should paste your codeIF Item."Discontinued Date" < (Item."Start Date" + 30) THEN MESSAGE('%1 was not a very good item',"No.");
Seems to work for me0 -
And what about using CALCDATE function?
:whistle:0 -
Good Morning,
My code is:IF "Due Date" > ("Due Date"+30D) ... END
"Due Date" is a field in the "Cust. Ledger Entry" table.0 -
Flashtn wrote:
IF "Due Date" > ("Due Date"+30D) ... END
Try this and the help for CALCDATE will help you.// if Date1 < (Date2 + 30D) then if (Date1 < CALCDATE('+30D',Date2)) then begin ...... end;
Sandeep Prajapati
Technical Consultant, MS Dynamics NAV0 -
Sandeep Prajapati wrote:Flashtn wrote:
IF "Due Date" > ("Due Date"+30D) ... END
Try this and the help for CALCDATE will help you.// if Date1 < (Date2 + 30D) then if (Date1 < CALCDATE('+30D',Date2)) then begin ...... end;
if (Date1 < CALCDATE('<30D>',Date2)) then begin
0 -
Flashtn wrote:My code is:
IF "Due Date" > ("Due Date"+30D) ... END
"Due Date" is a field in the "Cust. Ledger Entry" table.
How can due date ever be Greater than itself plus some more days?
are you sure one of the "due date" shouldn't be document date or posting date?IF Item."Discontinued Date" < (Item."Start Date" + 30) ...
Still worked in my test report - adding 30D instead of just 30 caused an error. Anyway I would still make "30 days" a variable that can be changed from some setup table.
We do something similar. Even tho an item is discontinued (blocked) we will allow it to be returned for (X) amount of days.
// CHECK FOR RETURNABLEIF (Item.Blocked) AND (Item."Discontinued Date" <> 0D) THEN DaysDiscontinued := WORKDATE - Item."Discontinued Date";
InvtSetup.GET; IF (("Document Type" IN ["Document Type"::"Return Order","Document Type"::"Credit Memo"]) AND Item."Can Not Return") OR (DaysDiscontinued > InvtSetup."Days Blocked-Not Returnable") THEN BEGIN IF NOT CONFIRM ('Item Not Returnable. Do you want to add item anyway?') THEN BEGIN MESSAGE('Please Delete This Item'); END END;
Where (X) is set in the Inventory Setup table in a field called "Days Blocked-Not Returnable". It's set this way just in case we one day want to increase or descrease the allowable time to return a discontinued item.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions