Oracle Date format exception in SQL Server Reporting Services

Trying to figure out the issue

I don't think the issue is related to the Visual Studio upgrade. It is related to the date format passed as a parameter to TO_DATE() function.

Based on the official documentation of the Oracle / PLSQL: ORA-01830 Error Message:

Cause: You tried to enter a date value, but the date entered did not match the date format.

In Oracle, the default date format is generally DD-MON-YYYY. If you try to enter a date value that does not comply with this format.

You seem to have passed the date parameters in the dd-MMM-yyyy format and now they are passed as MM/dd/yyyy.

First of all, check that the regional setting or the applications Culture information didn't change.


Possible workarounds

You can fix the issue using several approaches:

(1) Handling the parameters date format

If you do not want to edit all code, then it is easier to force the parameter data string format, make sure that all parameters passed to TO_DATE() function are in following format (or try to change the default date format from the OS regional settings):

dd-MMM-yyyy   example: 01-AUG-2019

(2) Adding the date format to TO_DATE function

If you are sure that the date parameters format is fixed and will not change then you can edit your code as you mentioned in the question:

To_Date(:Date_Parameter,’MM/DD/YYYY’)

(3) Pass the date and format as parameters

This also requires changing the code, but you will pass the date and format as parameters.

To_Date(:Date_Parameter,:DateFormat_Parameter)
  • SQLFiddle demo for parsing dates

You may find other methods at the following link:

  • ORA-01830: date format picture ends before converting entire input string / Select sum where date query

Update 1 - Making common change in multiple reports

While searching I found the following link providing a method to loop over reports and make changes. You have to only replace To_Date(:Date_Parameter) with To_Date(:Date_Parameter,’MM/DD/YYYY’):

  • SSRS - Make common change in multiple reports in one click

Update 2 - Other possible workarounds

Forcing Culture info by editing ReportViewer.aspx

You can edit the ReportViewer.aspx file is located in the SQL Server reporting services directory, and force the culture info used within reports. Check out the following question it will give you more details:

  • I want Datetime Parameter in DDMMYYYY Format in ssrs report

Changing the browser language settings

Check the following link (read Mike Honey and Nick St Mags answers):

  • SSRS Datetime Parameter value should display in DD/MM/YYYY format

Update 3 - Issue cause

In addition of what @DavidBrownie posted i found the SQL Server 2008 R2 documentation:

  • Oracle Connection Type (SSRS 2008 R2)

Where they mentioned:

This built-in data source type is based on the .NET Framework Managed Provider for Oracle and requires an Oracle client software component.

Also if you take a look at SQL Server 2017 documentation:

  • Oracle Connection Type (SSRS 2017)

This built-in data source type uses the Oracle Data Provider directly and requires an Oracle client software component.

In addition, referring to Microsoft OLE DB Provider for Oracle documentation (which is the old used provider). They mentioned that:

This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Instead, use Oracle's OLE DB provider.

Which is the reason for changing the provider used to connect to Oracle in Reporting Services.


what has changed in SSRS2017 vs SSRS2008R2

SSRS 2008 used the old System.Data.OracleClient. In SSRS 2016 and later you have to install the Oracle ODP.NET provider, built and supported by Oracle. So probably just a difference in how the NLS_DATE_FORMAT session parameter is set by the two drivers.

You can see your setting if you add a dataset to your report with this query:

select parameter, value 
from nls_session_parameters 
where parameter like 'NLS%'
order by parameter

Unfortunately there doesn't appear to be a way to globally change the client date format in Oracle.ManagedDataAccess, so you'll have to make all the changes in the report dataset queries.

Alternatively you can try to ensure that you are passing Date parameters and not string parameters. If you pass a date to Oracle's to_date() function, you don't need to specify a format.

The docs for SSRS 2014 "This built-in data source type is based on the .NET Framework Managed Provider for Oracle and requires an Oracle client software component."

And for SSRS 2016 "This built-in data source type uses the Oracle Data Provider directly and requires an Oracle client software component."