Click to See Complete Forum and Search --> : Convert DateTime to String


daniel50096230
June 16th, 2009, 09:25 AM
Hi, I had retrieve the data from SQL Server where the DateTime format in SQL Server is yyyy-MM-dd HH:mm:ss. How can I using C# code to change the DateTime format to yyyy-MM-dd???

boudino
June 16th, 2009, 09:31 AM
What type is the data returned from server? If it is DateTime, use simlpy ToString("yyyy-MM-dd"). Otherwise, you would have to convertr it to DateTime first. Look at Convert.ToDateTime() or DateTime.Parse().