Click here to Skip to main content
15,887,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to convert 10/14/2012 to 14/10/2012 in asp.net c#

Please help, Thanks.
Posted
Comments
Herman<T>.Instance 15-Oct-12 4:37am    
from string to datetime object or from datetime to datetime object ?
vivektiwari97701 15-Oct-12 4:37am    
your qus. is not clear .u want to convert date format or month to date ???
explain ur question.
ridoy 15-Oct-12 6:14am    
simply print as(dd/mm/yyyy)..

Try following
C#
string ST="";
ST = String.Format("{0:dd/MM/yy}",yourdate);
 
Share this answer
 
v2
Comments
bhargavpp 15-Oct-12 5:09am    
date.tostring("dd/mm/yy");
use this format
C#
date.tostring("dd/mm/yy");

hope this help
 
Share this answer
 
v2
Using this

XML
using System.Globalization;

DateTimeFormatInfo dtinfo = new DateTimeFormatInfo();
        dtinfo.ShortDatePattern = "MM/dd/yyyy";<pre></pre>
 
Share this answer
 
Try this:
C#
string date = "10/14/2012";
int year = Convert.ToInt32(date.Split('/')[2]);
int day = Convert.ToInt32(date.Split('/')[1]);
int month = Convert.ToInt32(date.Split('/')[0]);
DateTime dtOld = new DateTime(year, month, day);
string newDate = dtOld.ToString("dd/MM/yyyy").Replace('-', '/');

Hope it helps!
--Amit
 
Share this answer
 
v3
DateTime dt = Convert.ToDateTime(txtdate.Text);
String newdate = dt.ToString("DD/MM/YYYY");
 
Share this answer
 
Using this

Add this namespace in page
C#
using System.Globalization;


Then use this code

C#
DateTimeFormatInfo dtinfo = new DateTimeFormatInfo();
        dtinfo.ShortDatePattern = "MM/dd/yyyy";
 
Share this answer
 
 
Share this answer
 
Comments
safal.786 1-Mar-13 12:50pm    
correcmd. this code
cmd.Parameters.AddWithValue("@Birthdate1", txtbdate.Text);
safal.786 1-Mar-13 12:51pm    
correct this code

cmd.Parameters.AddWithValue("@Birthdate1", txtbdate.Text);

it shows error for date conversion
Member 10779791 29-Apr-14 6:16am    
i want convert date to word..
for example:
02/04/1990
o/p= two april ninteen ninty
plz help

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