NAV fill with last week range in a date field

catiamatos1991
Member Posts: 158
I'm trying to figure how to get the last week range to pass to a date field. I'm using the page 408 G/L Balance by dimension and my goal is to fill in the page open the column "DateFilter" with the last week until today (05/06/2018..today)
I tried to use the CALCDATE function and the option "CW" for the expression but I can't find the solution.. ('<-CM - %1W>')
I tried to use the CALCDATE function and the option "CW" for the expression but I can't find the solution.. ('<-CM - %1W>')
0
Best Answers
-
Look at CALCDATE function documentation
CM or +CM - end of the current month
-CW - beginning of the current week
CW or +CW- end of the current weekTheFirstDayOfLastWeekOfAMonth = CALCDATE('<+CM-CW>', SomeDate); //Monday TheLastDayOfLastWeekOfAMonth = CALCDATE('<+CM+CW>', SomeDate);//Sunday
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
Slawek_Guzek wrote: »FirstDate := CALCDATE('<-CW-1W>', TODAY);
or
FirstDate := CALCDATE('<-1W-CW>', TODAY);
or
FirstDate := CALCDATE('<CW-2W+1D>', TODAY);
or
FirstDate := CALCDATE('<-2W+CW+1D>', TODAY);
And rethink your career path.
Thanks, it worked. My career path? I didn't understand0
Answers
-
Look at CALCDATE function documentation
CM or +CM - end of the current month
-CW - beginning of the current week
CW or +CW- end of the current weekTheFirstDayOfLastWeekOfAMonth = CALCDATE('<+CM-CW>', SomeDate); //Monday TheLastDayOfLastWeekOfAMonth = CALCDATE('<+CM+CW>', SomeDate);//Sunday
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
but that will result in 10 for the first day and 16 for the last right? I want of the last week (3 to 9)0
-
CALCDATE expressions work sequentially in order of specification:
CALCDATE('<+CM-CW>', SomeDate) is equal to CALCDATE ('<-CW>'), CALCDATE('<+CM>', SomeDate) ).
NAV first calculates the first part of the expression CM (as if it was calculating the inner CALCDATE(+CM...)) - arriving at the end of the month, and then using just calculated end of month date calculates -CW expression arriving at the last Monday in a month given by the SomeDate (looking backwards it is the first Monday from specified date).
On the top of that (all of this is described in the CALCDATE function documentation:
-1W 'moves' the date one week back.
Now combine the above to build an expression which will give you a Monday one week back from the Monday in current week.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
So I'm getting the time range from 10/06/18 to 17/06/18 but my goal was to get the first period from last week.
FirstDate := CALCDATE('<CW-1W>', TODAY); //Monday
LastDate := CALCDATE('<+CW>', TODAY);//Sunday
How can I assign this range to my field "DateFilter"?0 -
catiamatos1991 wrote: »FirstDate := CALCDATE('<CW-1W>', TODAY); //Monday
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
I want to get the first day of the last week0
-
FirstDate := CALCDATE('<-CW-1W>', TODAY);
or
FirstDate := CALCDATE('<-1W-CW>', TODAY);
or
FirstDate := CALCDATE('<CW-2W+1D>', TODAY);
or
FirstDate := CALCDATE('<-2W+CW+1D>', TODAY);
And rethink your career path.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03-1 -
Slawek_Guzek wrote: »FirstDate := CALCDATE('<-CW-1W>', TODAY);
or
FirstDate := CALCDATE('<-1W-CW>', TODAY);
or
FirstDate := CALCDATE('<CW-2W+1D>', TODAY);
or
FirstDate := CALCDATE('<-2W+CW+1D>', TODAY);
And rethink your career path.
Thanks, it worked. My career path? I didn't understand0 -
It seems to me that you did not try to understand and learn what CALCDATE expressions do, you were only after made ready solution - a line of code which can be copied and pasted.
Programming is about thinking and understanding, and, first and foremost, persistent, never ending learninig. Programming is not about copying lines of code from forums or other sources. If you are not into thinking and learninig too much maybe programming is not the right job choice for you.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031 -
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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