Reputation: 45
I want to Get date-time Format like (30 April 1990) my date is store in sql server Database in default Format mm/dd/yyyy. how to do that?
tsddate.Text = orderReader["deliveryDate"] as DateTime = new DateTime(?,,????);
Upvotes: 0
Views: 237
Reputation: 2171
tsddate.Text = String.Format("{0:dd MMMM yyyy}",orderReader["deliveryDate"]);
Upvotes: 1
Reputation: 2585
You can specify custom datetime formats using the ToString overload.
like:
DateTime now = DateTime.Now;
string formatted = now.ToString("dd-MM-yyyy");
And in your situation it would be something like:
DateTime date = DateTime.ParseExact(orderReader["deliveryDate"].ToString(), "MM/dd/yyyy HH:mm:ss", new System.Globalization.CultureInfo("en-US"));
tsddate.Text = date.ToString("dd MMMM yyyy");
see all the formats you can use here: http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
Upvotes: 2