Reputation: 63
Hi I am having an application which uses oracle as backend. what is the correct format while passing the parameters to stored procedure from c sharp? If the format is dd-mmm-yyyy. i.e 30-jan-2011. How to convert a date which is in mm/dd/yyyy (01/30/2011) to dd-mmm-yyyy (30-jan-2011)?
Upvotes: 0
Views: 1488
Reputation: 31630
You could use :
dt.ToString("dd-MMM-yyyy")
dt being your DateTime variable
Upvotes: 1
Reputation: 9861
You should load the value into a DateTime
type with a parse, and output with a ToString()
var d = DateTime.ParseExact("01/30/2011","mm/dd/yyyy");
string readyForOracle = d.ToString("dd-MMM-yyyy");
ParseExact method docs:
http://msdn.microsoft.com/en-us/library/system.datetime.parseexact.aspx
DateTime custom formatting docs:
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Upvotes: 2
Reputation: 641
String.Format("{0:mm/dd/yyyy}", date); // 01/30/2011
String.Format("{0:dd-MMM-yyyy}", date); // 30-jan-2011
Upvotes: 0