Tuesday, September 3, 2013

Oracle Date Format And Compare













Oracle dates have a different format than SQL Server dates. So to select a date for the Oracle database you have to have the date in the following format.  
string myDate = "10/9/2012 2:55:25 PM";

string sql = "SELET * FROM SomeTable WHERE SomeDateField=" +
"to_date('" + myDate + "','" + "MM/DD/YYYY HH:MI:SS " +
myDate.Substring(myDate.Length - 2) + "');";

No comments:

Post a Comment