Calculate date

Navi_Learner
Member Posts: 356
Hi I have a question. In our current Cash report, we have the posting date, and the due date. How to calculate the days when custoer pay the cash, i.e due date - posting date. I tried it, but it didn't work. Thanks in advance!
0
Comments
-
"Due date" - "Posting date" should work fine. It returns an integer, which is the number of days between both dates.0
-
I create a variable with integer data type, but when I minus the two, the result is zero. So how can I get the correct number? Thanks!0
-
That's because your dates are the same? When I do Date1 - Date2 I get an integer with the number of days, I don't know how else to put it.0
-
I had created a little form to test it myself, and figured maybe you'd want to see how I got it to work:
OBJECT Form 50000 Date Minus Date { OBJECT-PROPERTIES { Date=01/19/06; Time=12:24:17 PM; Modified=Yes; Version List=; } PROPERTIES { Width=5610; Height=2200; OnOpenForm=BEGIN Date2 := TODAY; Date1 := CALCDATE('<-10D>',Date2); END; } CONTROLS { { 1000000000;TextBox;3630 ;220 ;1700 ;440 ;CaptionML=ENU=Date 1; SourceExpr=Date1 } { 1000000001;Label ;220 ;220 ;3300 ;440 ;ParentControl=1000000000 } { 1000000002;TextBox;3630 ;770 ;1700 ;440 ;CaptionML=ENU=Date 2; SourceExpr=Date2 } { 1000000003;Label ;220 ;770 ;3300 ;440 ;ParentControl=1000000002 } { 1000000004;CommandButton;220;1430;5060;550;CaptionML=ENU=Date 2 Minus Date 1; OnPush=BEGIN MyInteger := Date2 - Date1; MESSAGE(FORMAT(MyInteger)); END; } } CODE { VAR Date1@1000000000 : Date; Date2@1000000001 : Date; MyInteger@1000000002 : Integer; BEGIN END. } }
Save it in a text file and import it into Navision. It's a form with object number 50000. If that number is already taken, just change the number to one that is available.0 -
I don't have the liscence to import the file. I changed something. Now almost all the number are -30 whether it is paid before the due date or after the due date except the number that is paid at exact due date is correct that is zero. I still don't why. Can it give me for instance 20, 8 and etc after I minus the two date?0
-
I really don't know how else to explain it.... You subtract two dates and it returns an integer. This works all the time. If date 1 is before date 2 it returns a positive number, a negative number if it's after date 2, and zero if it's the same.
If you're not getting the right results then you're not programming it correctly. If it's in a report you typically want to do this in the OnAfterGetRecord trigger of the relevant dataitem. You can even put the source expression of the control to be "Posting Date" - "Due Date" and it will show the number.0 -
post your code, variables, where you're doing this & what trigger you are using. then we can see where you are going wrong.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