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???
Printable View
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???
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().