How to increment a Date field?

Aravindh_Navision
Member Posts: 258
Hi Pals,
I need to increment date by 1 month each from a given date for 12 month. I am doing this in report in OnPreReport() trigger.
For eg.: Date input: 01/03/2012. (1st month)
It should get increment by 1 month (for 12 months).
01/04/2012 (2nd month)
01/05/2012 (3rd month)
-
-
-
01/13/2013 (12th month)
Can anyone help me how to do it?
Thanks in advance,
Aravindh
I need to increment date by 1 month each from a given date for 12 month. I am doing this in report in OnPreReport() trigger.
For eg.: Date input: 01/03/2012. (1st month)
It should get increment by 1 month (for 12 months).
01/04/2012 (2nd month)
01/05/2012 (3rd month)
-
-
-
01/13/2013 (12th month)
Can anyone help me how to do it?
Thanks in advance,
Aravindh
0
Answers
-
Check Report 120 how Date is calculated based on Period Length0
-
Thanks for you reply Mohana. May I know the report name? Report 120 is not there in my DB.0
-
Aged Accounts Receivable...I am using IN Version of 2009 R2..0
-
Define Global Variables PeriodLength as DateFormula
NewDate as Date
Eg
EVALUATE(PeriodLength,'1M');
NewDate := CALCDATE(PeriodLength,140212D);0 -
sameerar wrote:Define Global Variables PeriodLength as DateFormula
NewDate as Date
Eg
EVALUATE(PeriodLength,'1M');
NewDate := CALCDATE(PeriodLength,140212D);
This is language dependent! Although month is often translated to another word starting with an m there is no guarantee that it always will.
Language independent version:EVALUATE(PeriodLength,'<1M>'); NewDate := CALCDATE(PeriodLength,140212D);[/
also read up on dateformulas and maybe even the virtual Date table.0 -
Actually this is working. But where I got struck is displaying the date for 1 month interval up to NoofTimes.
Variables
The below inputs I will give in report's request form.
NoofTimes - integer
DueDate - date
I wrote the below coding in OnPreReport().boolDate := FALSE; FOR intI := 1 TO NoofTimes DO BEGIN IF DocumentType = DocumentType::"Posted Invoice" THEN BEGIN CLEAR(NewDueDate); IF boolDate THEN BEGIN EVALUATE(PeriodLength,'1M'); NewDueDate := CALCDATE(PeriodLength, DueDate); recSalesHeader."Due Date" := NewDueDate; MESSAGE('%1', NewDueDate); END ELSE BEGIN recSalesHeader."Due Date" := DueDate; MESSAGE('%1', DueDate); END; END; boolDate := TRUE; END;
For example:
Input:
NoofTimes = 5
DueDate = 01/03/2012
I am getting the correct values for 1st and 2nd. From 3rd to 5th I am getting the same value which is same as 2nd which is wrong. That is..1. 01/03/2012 2. 01/04/2012 3. 01/04/2012 4. 01/04/2012 5. 01/04/2012
I must get..1. 01/03/2012 2. 01/04/2012 3. 01/05/2012 4. 01/06/2012 5. 01/07/2012
What to do to get this?0 -
Hint - "boolDate"0
-
The Reason is DueDate is not Updating every time
Try this codeboolDate := FALSE; FOR intI := 1 TO NoofTimes DO BEGIN IF DocumentType = DocumentType::"Posted Invoice" THEN BEGIN CLEAR(NewDueDate); IF boolDate THEN BEGIN EVALUATE(PeriodLength,'1M'); NewDueDate := CALCDATE(PeriodLength, DueDate); DueDate := NewDueDate; // New Code recSalesHeader."Due Date" := NewDueDate; MESSAGE('%1', NewDueDate); END ELSE BEGIN recSalesHeader."Due Date" := DueDate; MESSAGE('%1', DueDate); END; END; boolDate := TRUE; END;
0 -
Thats fantastic. \:D/ It is working fine and getting the desired output.
:thumbsup: Thanks a lot Mohana, Sameer, Sog for your replies and help.0 -
Aravindh_Navision wrote:Thats fantastic. \:D/ It is working fine and getting the desired output.
:thumbsup: Thanks a lot Mohana, Sameer, Sog for your replies and help.
welcome0
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