Convert date format


I am reading a date column from SQL with this format “1900-01-01 00:00:00:00”
I want to convert it to 01/01/1900.

How ?


Hi, please refer this. might be work.


Declare a datetime variable as convertedDate
Assign to a date variable: Convert.ToDateTime(“yourSQLDateString”).Date

Then you can convert it to the required format as

DateTime.ParseExact(convertedDate.ToString(“yyyy-MM-dd hh:mm:ss:ms”), “yyyy-MM-dd hh:mm:ss:ms”, Nothing).ToString(“dd/MM/yyyy”)

1 Like


Try this:

     DateTime.ParseExact("1900-01-01 00:00:00:00", "yyyy-MM-dd HH:mm:ss:ms", System.Globalization.CultureInfo.InvariantCulture).Tostring("dd/MM/yyyy")