I am relatively new to C# and any suggestions to the query below i will greatly appreciate.
I've gone through a lot of articles here but none of the solutions seems to work in my case
Im reading DATETIME from sql and passing it to a string
dateStart = rd1["DATE_START"].ToString();
when debugging in VS it's showing date time in a format i like: 22/11/2015 17:12:45 But Label is showing 11/22/2015 5:12:45 PM
When i use the code to ParseExact
dtime = DateTime.ParseExact(dateStart, "yyyy/MM/dd HH:mm:ss", provider);
No matter what i use for the format i always get
[FormatException: String was not recognized as a valid DateTime.]
DateTime dtime;
CultureInfo provider = CultureInfo.InvariantCulture;
provider = new CultureInfo("en-GB");
dateStart = rd1["DATE_START"].ToString();
dtime = DateTime.ParseExact(dateStart, "yyyy/MM/dd HH:mm:ss", provider);
LBDateOpened.Text = dtime.ToString();
I'm lost, please help.
DATETIMEtype? If that were the case, you could just(DateTime)rd1["DATE_START"], which is significantly better than parsing it yourself.ParseExactdoesn't look, well, exact to the source string.