How to calculate previous months first date and last date?

Aravindh_Navision
Member Posts: 258
Hi Pals,
How to calculate previous months first date and last date using the Date Filter given in report? For Eg.: While running a report, I am giving the Date Filter as 01/04/12..30/04/12. Using GETRANGEMIN, GETRANGEMAX function, I am storing the Start Date and End Date in 2 variables.
My aim is to get the previous month's Start date and End Date. That is: I need to get march month's Start Date as 01/03/12 and End Date 31/03/12. Am aware this is something to do with CALCDATE function, but what is the formula? How can I achieve this?
Thanks in advance.
Aravindh R.
How to calculate previous months first date and last date using the Date Filter given in report? For Eg.: While running a report, I am giving the Date Filter as 01/04/12..30/04/12. Using GETRANGEMIN, GETRANGEMAX function, I am storing the Start Date and End Date in 2 variables.
My aim is to get the previous month's Start date and End Date. That is: I need to get march month's Start Date as 01/03/12 and End Date 31/03/12. Am aware this is something to do with CALCDATE function, but what is the formula? How can I achieve this?
Thanks in advance.
Aravindh R.
0
Answers
-
How about you open the help and look at the dateformula topic?
Goes alot faster than waiting for a reply.0 -
did you try with
CALCDATE('<-1M>',<Startdate>) CALCDATE('<-1M>',<enddate>)
0 -
Date1 := CALCDATE('<-1M>', "Start Date");
Date2 := CALCDATE('<-1M>', "End Date");
Chn0 -
Hi Mohana/Chinmoy,
Thanks for your reply. I tried the formula that you mentioned already. This formula gives the date value of:
Input: Date Filter: 01/04/12..30/04/12.
PrevStartDate : 01/03/12
PrevEndDate : 30/03/12
I need PrevEndDate as 31/03/12, since March month contains 31 days. But I am getting PrevEndDate as 30/03/12. Also how to handle for February month 28days (29 days in leap year)?
Thanks,
Aravindh.0 -
Use
CALCDATE('<CM>',Prevstartdate)
0 -
One more simple solution, if the startdate is always the first date of the current month:
PrevEndDate := CALCDATE('<-1D>', StartDate);
Chn0 -
Hey dude.. It worked
Thank you Chinmoy, Sog, Mohana for your suggestions. :thumbsup: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