Skip to Main Content



For appeals, questions and feedback, please email

Set dates format with ODP.NET managed driver

Laura MMar 5 2024


I have a program for executing querys about Oracle Database. My program used to use ODP.NET unmanaged driver and I need to configure dates format before execute the query.

I did it this way with ODP.NET Unmanaged:

OracleGlobalization og = OracleGlobalization.GetClientInfo(); 
og.DateFormat = "DD/MM/YYYY  hh24:mi:ss"; 

OracleCommand cmd = new OracleCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.CommandText = “select…”;

OracleDataAdapter datAdapt = new OracleDataAdapter(cmd);
//I need to use ODP.NET types instead of .NET types
datAdapt.ReturnProviderSpecificTypes = true;  

DataSet ds = new DataSet();

This code works fine until I change to ODP.NET managed driver. I couldn't use Thread and client info for globalization because it's not supported in ODP.NET managed so I though to use session info instead. Then, when dataset contains any column of type OracleDate, it shows like American (MM/DD/YYYY) instead of Spanish (DD/MM/YYYY). It seems that Session info doesn't apply.

New code:

OracleGlobalization info = con.GetSessionInfo();   
info.DateFormat = "DD/MM/YYYY  hh24:mi:ss"; 
info.TimeStampFormat = "DD/MM/YYYY  hh24:mi:ss";
info.DateLanguage = "SPANISH";

How could I set the language for dates with Managed driver?

I have noticed that if I set datAdapt.ReturnProviderSpecificTypes to false (using .NET types instead of ODP.Net types) the .NET object “System.Datetime” shows dates properly, but with other types like “System.string” instead of OracleCLOB (ODP.NET type) I'll lost data because of System.String can store less characters.

What is the solution for ODP.NET managed driver?

I use Oracle.ManageddataAccess 21.13.0 (from nuget repository)

Thank you very much!

Post Details
Added on Mar 5 2024
1 comment