Hello,
I'm fairly new to C/SIDE and don't know if I've made the right conclusions. I seems to me that there is a bug in CALCDATE. The code i've tried is CALCDATE('<CM-1M+1D>',WORKDATE). I'm trying to get the first date of the month that includes the current workdate. If Workdate is in February it returns 070129. If it's in April the returnvalue is 070331. Works for January and Mars though. It always withdraws 31 days. Also tried the following code for testing CALCDATE('<CM+1M>',WORKDATE). It returned for January 070228 (correct), february 070328 (wrong), Mars 070430 (correct) and April 070530 (wrong). Haven´t tried it for the rest of the year. BTW the dateformat in sweden is YYMMDD.
Am I missunderstanding something about CALCDATE or is it a bug? ](*,). If it´s a bug, does anybody know of a simple workaround?
Thanks in advance.
0
Answers
To be sure, I give all 3 possibilities:
datTheDate := 24042007D;
First day of current month:
Last date of current month:
Last date of next month:
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Its not a bug, you are missing something. Try
CALCDATE('<-CM>',WORKDATE)
RIS Plus, LLC
Correct using of CALCDATE:
First day of current month (as David wrote):
Last date of current month:
Last date of next month:
:-) It is easy. You need to know that if you do not enter +/-, + is used automatically.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thanks for all replies. I've tested the ones above and the first two worked just fine, using the workdate. (The first one was the one I wanted). But eager to learn as I am I tested all three. The last one works just fine for January and Mars. However, if workdate is in february it returns 070328, and if it's april it returns 070530. Same result (and same code) as in my previous attempt. Since my main problem is solved it's not important, but I would like to know if it's supposed to work like this. :-s
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Actually this is probably what Helm was thinking.
But +1m, actually finds the same date in the next month. So if you are in a month with 31 days it works, since the next month does not have 31 days, it rolls back to 28,29 or 30. But if you do this say in April, then CM give you April 30, +1m gives you May 30, where as you really want May 31, so the correct code is
CALCDATE('<1m+CM>',WORKDATE)
Opps sorry, I obviously had this open a long time. Still I am sure my explanation helps.
Actually when I first started in Navision (back in DOS days) I wrote a form that I used to learn CALCDATE.
I converted it to Windows some time ago to help explain CALCDATE to a client.
I have uploaded it on my site here:
http://www.go-live.us/downloads.htm
Feel free to use it for training purposes.
You were two fast, I was uploading whilst you were trying to down load.