calcuting date difference between two consecutive dates

asembereng
Member Posts: 220
I want to calculate the date difference between two posting date on the Cust. Ledger Entry table. how can i achieve this? this is what i have written so far to get what i want but its not working.
steps:="Cust. Ledger Entry".next(1);
steps := "Cust. Ledger Entry1".next();
start := "Cust. Ledger Entry"."Posting date";
"Cust. Ledger Entry1".next();
enddate := "Cust. Ledger Entry1"."Posting Date";
diff := enddate - start;
steps:="Cust. Ledger Entry".next(1);
steps := "Cust. Ledger Entry1".next();
start := "Cust. Ledger Entry"."Posting date";
"Cust. Ledger Entry1".next();
enddate := "Cust. Ledger Entry1"."Posting Date";
diff := enddate - start;
0
Comments
-
for example
31/01/08
29/02/08
23/07/08
28/12/080 -
And where is there your problem?
If you need the Days between the Start and End you can use also the DATE tableDo you make it right, it works too!0 -
I dont know how to achieve it using the date table. the data set is in a columnar form, taking the one underneath and doing the logic. thats my problem. Can you help me out, please?0
-
Hi,
You will need to give us us a more detailed explaination. It sounds like you want to use a matrix form. Have a look at budgets from 113 or the Howto
http://www.mibuso.com/howtoinfo.asp?FileID=130 -
I looked into the matrix form but that is not what i want. I am doing this on a report. this report is getting data from the cust. ledger entry table. I want to calculate the number of days between two consecutive posting date. For example, if i have two entries like the ones below
posting date amount
01/01/08 1000
01/04/08 200
i want something that will give me the days different between
01/04/08 - 01/01/08
thanks.. I hope that helps to explain.0 -
I just tried on a little testform, and Subtracting 2 DATe variables will give you the number of days in between. You already do that in your code, so what is the problem you are experiencing ?0
-
its not working and i can't figure out why?0
-
Hi
Are you doing this in onaftergetrecord of "Cust. Ledger Entry" DataItem?
Are you getting wrong data(Record) printed on report?
start := "Cust. Ledger Entry"."Posting date";
"Cust. Ledger Entry1".next();
enddate := "Cust. Ledger Entry1"."Posting Date";
diff := enddate - start;
By looking at code posted by you, it must have been printing the every second record.
If you are trying to print every record then you have to use
start := "Cust. Ledger Entry"."Posting date";
IF "Cust. Ledger Entry1".next() THEN BEGIN
enddate := "Cust. Ledger Entry1"."Posting Date"
diff := enddate - start;
"Cust. Ledger Entry1".next(-1) // This is to take the Pointer back by one
END ELSE BEGIN
diff := 0;
END;
Regards
Harjot0 -
Yes i am doing it on after get record and its displaying wrong duration. I tried your version but its diplsying sn error of integer to boolean telling me it should have true/false on this line
IF "Cust. Ledger Entry1".next() THEN BEGIN
thanks0 -
Hi
Sorry my mistake
Change the Line
IF "Cust. Ledger Entry1".next() THEN BEGIN
To
IF "Cust. Ledger Entry1".next() <> 0 THEN BEGIN
Regards
Harjot0
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