Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All ,

I have value in textbox as Fri Jul 15 19:22:31 2011
and wan to change in date tine format .

Please help.

Thanks
Mohd. wasif
Posted

if you are using simple datetime function then write as::
C#
DateTime.Now.ToString("dd/MM/yyyy");

and if you are using calender control then write as:
C#
string date = Calendar1.SelectedDate.ToString("dd/MM/yyyy");


but remember that datatype of particular column should be vaerchar
 
Share this answer
 
v2
Comments
Uday P.Singh 28-Sep-11 8:11am    
use code block
bkthebest 29-Sep-11 1:00am    
thanks uday,
i'll remember
 
Share this answer
 
v2
Comments
Arun Jacob 28-Sep-11 8:08am    
Just a suggestion : It would be nice if we post some inline comments along with the links. Thank you.
Hi,

try this code for converting time format

C#
string dfrmt = "Fri Jul 15 19:22:31 2011";
         string[] sd = dfrmt.Split(' ');
         string dt = System.DateTime.Now.ToString();
         int month = DateTime.Parse("1." + sd[1] + " 2008").Month;

         DateTime dth = new DateTime(int.Parse(sd[4]), month, int.Parse(sd[2]), int.Parse(sd[3].Split(':')[0]), int.Parse(sd[3].Split(':')[1]), int.Parse(sd[3].Split(':')[2]));

         string st = month  + "/" + sd[2] + "/" + sd[4] + " " + dth.ToLocalTime().ToLongTimeString();


By using this code you can convert your required datetime format

All the Best
 
Share this answer
 
refer this link any type of conversion you want

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^]
 
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