There mught be some kind of culture clash going on. If SSRS is sending dd/mm/yyyy and your db is expecting mm/dd/yyyy things will not work as expected or even crash on certain dates.
Query works in Query Designer but not in MS SQL Server Report Builder
-
13-07-2023 - |
Question
While using the Microsoft SQL Server Report Builder, I am able to execute a query in the Query Designer and retreive the result. The query has a where clause on dates.
select * from table where DB_timestamp > to_date(:StartDate, 'mm/dd/yyyy') and DB_timestamp < to_date(:EndDate, 'mm/dd/yyyy')
On execution, I get a pop up where I enter the two variables (StartDate & EndDate) in the given formats. Now when I try to run the same for generating a report, I have to select the two variables using a calender picker. Altough the dates show up in the desired format, I always get the below error:
An error occured during local report processing.
Query execution failed for dataset 'XYZ'.
ORA-01843: not a valid month
What can cause the query to run successfully in one place but throw an error when the variables are selected by the calender picker?
La solution
Autres conseils
I would remove the to_date function from the where clause, e.g.
where DB_timestamp > :StartDate and ...