My report has a finishdate column which is grouped into week intervals, Im trying to run the following formula to get the Saturday(end of the week) based on the finishdate e.g if the finish date is 4/7/2006 which is a Tuesday, I want to find out what the end off week date is - which would be 8/7/2006 (Saturday) and place this into another column.
NumberVar whatday;
whatday = dayofweek({finishdate});
If whatday = 2 then //monday
{finishdate} + 5;
Else whatday = 3 then
{finishdate} + 4;
Else whatday = 4 then
{finishdate} + 3;
Else whatday = 5 then
{finishdate} + 2;
Else whatday = 6 then
{finishdate} + 1;
This is not returning any errors but also it is giving me just a blank output. Also when i run the lines
{finishdate} + 4;
on its own, the dates are adding up correctly
OR
dayofweek({finishdate}) onit owns it returns the correct day off week for the finishdate
when i put variables
NumberVar whatday;
whatday = dayofweek({finishdate});
If whatday = 2 then //monday
{finishdate} + 5;
i get a day returned off 1/1/-4713 or an incorrect dayofweek
I have no idea why this is returned.
I am using Crystal Report 7 and the dateadd() is not available, I dont know why when run with conditions etc such as if and variable declarations, it doesnt return the right date, but when run on its own it works.
Can someone help,
thanksThe common mistake people do with Crystal, is when they forget there are two different syntaxes: Crystal and VB. In your case, I think the problem is in assignment operator. Try whatday := dayofweek({finishdate}); instead of whatday = dayofweek({finishdate}); The latter would return the boolean value as a result of comparision, not assignment.
Sunday, February 19, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment