Monday, March 19, 2012

How to take off the time part of the parameter

Hello,

How can I display data that only compare the date part (ignoring the time part) between the value of the date parameter and the database?. It displays data only if I pass the whole date (date and time)

I tried with the following query in the report services 2000, but it even didn't pass the query parse

SELECT * FROM table

WHERE (CONVERT(CHAR(8), table.PRODUCTION_DATE, 112)
= CONVERT(CHAR(8), @.parameterDate, 112))

Any ideas will be appreciated.

Thanks,

Marco

What are the data types of the column and the parameter, and what error do you get when you say it doesn't get past the parse step?|||

The message is ADO error: Line 1: Incorrect syntax near ')'

If I replace @.parameterDate with a string e.g. '' The parse is ok

I tested the same query in RS 2005 and it passes the parse

Both the column and the parameter are datetime data types

Thanks

|||

Just in case someone has the same problem:

I realized that the workaround to this is to change the sql expression entering two dates as parameters, fromDate and toDate and using the where clause as follows:

where databaseDate => @.fromDate and databaseDate <= @.toDate

regards

Marco

No comments:

Post a Comment