Date, Types, Formats and Conversions – The bane of my life.-Collection of common programming errors

I never seem to get away from issues in this area.

I have written a report in Crystal Reports 2008 along with many others and I am using a VB.net 2010 application that has a Reports Page holding a Crystal Reports viewer (CR13 and .Net Version 4 framework). I pass over parameters where necessary from within the Application.

I have just finished writing the next report in Crystal Reports 2008 that I am going to use within the application.

The report works fine from within Crystal Reports. I tested it with my application as it was without passing parameters. Upon runtime the expected parameters dialog appeared and I enter a month and year value as normal. And received this error;

So I toyed around with the selection criteria and tried all sorts of combinations of YYYY-MM-DD, YYYY/MM/DD, YYYY,MM,DD and the reverse combinations of those; DD/MM/YYYY etc.

This is the record selection it doesn’t like. I’ll add once again that, all the variations of the date formats I have tried all work when running the report from within Crystal Reports, they all fail with the above error when running the report from within my VB Application. All other reports in my VB application all work perfect. It is just this report.

This is just one of the selection criteria versions I have tried that works in Crystal but not in my application;

//All months not January and December

If {?Month}  1 and {?Month}  12 then 

(cdate({workingday.workingday_date}) >= cdate(int({?Year}) & "-" & int({?Month}-1) & "-" & 15) and

cdate({workingday.workingday_date}) < cdate(int({?Year}) & "-" & int({?Month}) & "-" & 15))


else


// January

If {?Month} = 1 then 

(cdate({workingday.workingday_date}) >= cdate(int({?Year}) & "-" & int({?Month}) & "-" & 1) and

cdate({workingday.workingday_date}) < cdate(int({?Year}) & "-" & int({?Month}) & "-" & 15)) 
else

//December

If {?Month} = 12 then 

(cdate({workingday.workingday_date}) >= cdate(int({?Year}) & "-" & int({?Month}-1) & "-" & 15) and

cdate({workingday.workingday_date})