I am using Crystal Reports 2008, and CR 2008 Server. One of the Views we are using has different fields for Month and Year, both Calendar and Fiscal. I need to be able to combine the Month Year, when the user wants to select a date range she will be able to select 11/2011 through 6/2012 right now she has to select Month 1-12 and then Year 2000 - 2012. Doesn’t get the data she needs.
Part of the problem is that when you have the date in the format mm/yyyy as a string, it sorts like a string. For example:
1/2012
1/2013
10/2012
2/2012
So, using “between” with month and year in that format won’t get you the results you need.
One option to get around this would be to format the parameters as yyyy-mm and force a leading 0 on the month when it’s prior to October. The above sample would then sort like this:
2012-01
2012-02
2012-10
2013-01
Or you could set up the parameters in the mm/yyyy format you’re looking for and create a formula to convert them to yyyy-mm.
You would then also create a SQL Expression (assuming you’re using just views and/or tables and not any commands) that looks something like this:
Use this SQL Expression in your selection criteria along with the parameters to get what you’re looking for. If you can’t create a SQL Expression, you could use a formula to do the same thing. The problem with using a formula is that Crystal will bring all of the data in the view into memory and filter it there instead of letting the database do the work.
Hi, thanks for your input, but I am still learning how to create new formulas.
Is there a formula that can be used to combine the month and year fields?