I am trying to set up code to automatically filter a report to Shipment Date = Current month. NOT the past 30 days, just whatever the current month is. Is there a way to do this using CM, Month, D1? The compiler does not recognize anything except (TODAY) ](*,)
0
Answers
+CM -> End of the month
(Of course used in CALCDATE function)
I hope that I am correct... :-) just test it, you will see...
Or take Date table, filter it for months, with beginning ..TODAY and ending TODAY.. and first record matching that will tell you more...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The problem I am having is when I try to use CM the compiler says:
Microsoft Dynamics NAV Classic
You have specified an unknown variable.
CM
Define the variable under 'Global C/AL symbols'.
OK
I need something like this: (I know this is probably not the correct format)
SL is sales line table.
I need the report to filter on all items with Shipment date within current month.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thank you so much!
Can I trouble you for one more detail? I just realized that I do not want TODAY. I want from -CM to + CM (Beginning of Month to End of Month). I tried changing TODAY to +CM but it would not compile.
Microsoft Dynamics NAV Classic
Type conversion is not possible because 1 of the operators contains an invalid type.
Date := Text
OK
declaring monthStart and monthEnd isn't strictly necessary, you can put the calcdate function into the SETRANGE like in your example, I just did it like this for clarity
Programming these things is not difficult once you are aware of how you take care of the proper data types, and once you learn how to convert them properly. The C/SIDE Reference Guide is an excellent source of syntax help.
RIS Plus, LLC
that is the best advice Denster.
Yeah I know I know. :whistle:
I have been looking at the C/AL guide and specifically CalcDate(). I also tried to find other reports which would have code to filter on the current month. I would much rather understand it than just get an answer - but since we are in a time crunch I was hoping for some help on here.
in Help we have:
NewDate := CALCDATE(DateExpression [, Date])
So
DateExpression = '<CM>'
Date = a "reference date." TODAY
And now I know this works: CALCDATE('<-CM>', TODAY)
Again from HELP
Record.SETRANGE(Field [,FromValue] [,ToValue])
So...
SL.SETRANGE("Shipment Date", CALCDATE('<-CM>', TODAY), CALCDATE('<+CM>', TODAY)); [-o<
It compiles! \:D/
Edited to add: And it works too!
RIS Plus, LLC