TheFirstDayOfLastWeekOfAMonth = CALCDATE('<+CM-CW>', SomeDate); //Monday TheLastDayOfLastWeekOfAMonth = CALCDATE('<+CM+CW>', SomeDate);//Sunday
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.
Answers
CM or +CM - end of the current month
-CW - beginning of the current week
CW or +CW- end of the current week
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
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.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
FirstDate := CALCDATE('<CW-1W>', TODAY); //Monday
LastDate := CALCDATE('<+CW>', TODAY);//Sunday
How can I assign this range to my field "DateFilter"?
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
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.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Thanks, it worked. My career path? I didn't understand
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.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!