I am trying to remove the time zone from a string.
The string looks like below.
2/05/2018 6:54:00 AM
This data has been retrieved from a local database.
Code Part:
string datCommisioned = (rdr.GetValue(4).ToString());
string dateonly = datCommisioned.ToString("dd/MM/yyyy");
When I tried to execute the above coding it's getting an error,
cannot convert from 'string' to 'System.IFormatProvider'
Any idea how to catch the date part excluding the time? Thanks!
Edit: This is probably not a duplicate question as I refer the other questions before posting. The context of this question is different because the string I'm extracting is not recognised as a valid DateTime (Manually entered by users) thus DateTime class cannot be used.