Calculate date.

Visi_V
Member Posts: 8
Hello.
Im new to Navi and i have a question:
How do i calculate date så every time i add a number it will print the same line X times with different date
I will use it when an employee is sick for 5 days, i should be able to print out new line for each day employee is sick.
example:
StartDate: 01/01/2016
I want to add 5 days to start date (a column), and it should print out a line from start date to 5 days forward.
Message('Date: %1', StartDate);
So every time it loop through it will add 1 day to the current startdate
so it will print out like this:
Output:
Date: 01012016
Date: 02012016
Date: 03012016
Date: 04012016
Date: 05012016
Im new to Navi and i have a question:
How do i calculate date så every time i add a number it will print the same line X times with different date
I will use it when an employee is sick for 5 days, i should be able to print out new line for each day employee is sick.
example:
StartDate: 01/01/2016
I want to add 5 days to start date (a column), and it should print out a line from start date to 5 days forward.
Message('Date: %1', StartDate);
So every time it loop through it will add 1 day to the current startdate
so it will print out like this:
Output:
Date: 01012016
Date: 02012016
Date: 03012016
Date: 04012016
Date: 05012016
0
Best Answer
-
Not sure what you do and don't know, so here are a few links that you can check out:
To calculate a date from a reference date: https://msdn.microsoft.com/en-us/library/dd301368.aspx
Here is more information about dates and times in C/AL: https://msdn.microsoft.com/en-us/library/dd338710.aspx
By the way, there are version specific details about some of those, and you can select the version that you need at the top of most of the MSDN pages.
The top level MSDN link for the C/SIDE Reference Guide: https://msdn.microsoft.com/en-us/library/dd301468(v=nav.90).aspx
General link for development in NAV: https://msdn.microsoft.com/en-us/library/dd338764(v=nav.90).aspx
I think that should be a good start.5
Answers
-
FOR i := 1 TO 5 DO Message('Date: %1', StartDate + i -1);
...where i is an Integer variable0 -
Not sure what you do and don't know, so here are a few links that you can check out:
To calculate a date from a reference date: https://msdn.microsoft.com/en-us/library/dd301368.aspx
Here is more information about dates and times in C/AL: https://msdn.microsoft.com/en-us/library/dd338710.aspx
By the way, there are version specific details about some of those, and you can select the version that you need at the top of most of the MSDN pages.
The top level MSDN link for the C/SIDE Reference Guide: https://msdn.microsoft.com/en-us/library/dd301468(v=nav.90).aspx
General link for development in NAV: https://msdn.microsoft.com/en-us/library/dd338764(v=nav.90).aspx
I think that should be a good start.5 -
FOR i := 1 TO 5 DO BEGIN
RecordVar.RESET;
RecordVar.SETRANGE(some filter you need);
....
IF Recordvar.FINDLAST THEN
DateVar :=RecordVar.Date + 1D
ELSE
DateVar := Your start date.
I guess...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