Solved

How to make an array of dates in Crystal

Posted on 2011-03-15
7
1,536 Views
Last Modified: 2012-05-11
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:

BeforeReadingRecords;
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
Comment
Question by:DSIGRIS
  • 4
  • 3
7 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 35140750
Try it this way

BeforeReadingRecords;
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
 
LVL 100

Expert Comment

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

http://www.kenhamady.com/form01.shtml

mlmcc
0
 

Author Comment

by:DSIGRIS
ID: 35141155
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.
BeforeReadingRecords;
DateVar Array Holidays := [Date (2003,12,25), Date (2003,12,31)];

But this gives me an error.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 100

Expert Comment

by:mlmcc
ID: 35141517
You need a final line that is a scalar value like ""

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

mlmcc
0
 

Author Comment

by:DSIGRIS
ID: 35141585
Why is that?
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 35143513
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.

If you had used
//Holiday Listing formula to go into the report header of the report.
BeforeReadingRecords;
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 Closing Comment

by:DSIGRIS
ID: 35149072
Great Job thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now