x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1904

# How to make an array of dates in Crystal

I need to check for holidays in my report.  I put this formula in the report header.

I have tried to make an array of dates in Crystal as follows:

Local DateVar Array Holidays:= MakeArray(Date(2011,01,01),Date(2011,12,25))

I get an error message that says "Result of formula cannot be an array"

How do I format the formula to create the array?
0
DSIGRIS
• 4
• 3
1 Solution

Commented:
Try it this way

Local DateVar Array Holidays:= [Date(2011,01,01),Date(2011,12,25)];
""

Crystal returns the value evaluated in the last line as the result of the formula.

mlmcc
0

Commented:
Not sure what you are doing but here is a formula that does the Number of WorkdDays between 2 dates and account for holidays

mlmcc
0

Author Commented:
I was trying to implement your solution for calculating the difference between two dates.

//Holiday Listing formula to go into the report header of the report.
DateVar Array Holidays := [Date (2003,12,25), Date (2003,12,31)];

But this gives me an error.

0

Commented:
You need a final line that is a scalar value like ""

//Holiday Listing formula to go into the report header of the report.
DateVar Array Holidays := [Date (2003,12,25), Date (2003,12,31)];
" "

mlmcc
0

Author Commented:
Why is that?
0

Commented:
Crystal returns the value from the last statement it executes or evaluates as the value of the formula.  In your case the declaration of the array so it tries to return the array as the value which is not allowed.

//Holiday Listing formula to go into the report header of the report.
DateVar Array Holidays := [Date (2003,12,25), Date (2003,12,31)];
numberVar HolidayCount := 2;

That would be fine because it would return 2 as the value.

Formulas on the report need to display something.

mlmcc
0

Author Commented:
Great Job thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.