Click here to Skip to main content
15,438,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey Guys,

I have a table with a date field that had date saved in the format of
yyyy-mm-dd, what i want to achieve is when I display them I want them to be displayed as an example "September 05 2009" format. can anybody help me with this??

Thank you very much.
Chetan
Posted

DateTime dt = new DateTime(2009,9,5);
            Console.WriteLine(dt.ToString("MMMM dd yyyy"));
 
Share this answer
 
v2
Comments
cnjadhav 22-Sep-10 12:11pm     CRLF
hey Shakil what does (2009,9,5); mean in the first line???? where is it coming from, can you please explain me that, because that is not the only date i want to change i have an entire table column bonded to a repeater???
Hiren solanki 23-Sep-10 2:22am    
You could see my answer below for binding to repeter.
Create a object of DateTime and try to parse the datetime in string to its format. You may use the code below :

DateTime dt = DateTime.ParseExact("2009-09-05", "yyyy-mm-dd");
Console.WriteLine(dt.ToString("MMMM dd yyyy"));



:)
 
Share this answer
 
You can Bind DateformatString to your Repeter Bound Field Like,

ASP.NET
<asp:boundcolumn datafield="DateTime" dataformatstring="{0:MMMM dd yy}" />
 
Share this answer
 
v2
Hi First you try to change the properties MM-DD-YYYY
 
Share this answer
 
Whatever is coming from database is ..just use
ToString("MMMM dd yy")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900