In an attempt to turn a date with a format of "mm/dd/yyyy hh:mm:ss PM"
into military time, the following replacement of a row value does not seem to take. Even though I am sure I have done this before (with column values other than dates). Is there some reason that row["adate"]
would not accept a value assigned to it in this case?
DateTime oos = DateTime.Parse(row["adate"].ToString());
row["adate"] = oos.Month.ToString()
+ "/"
+ oos.Day.ToString()
+ "/"
+ oos.Year.ToString()
+ " "
+ oos.Hour.ToString()
+ ":"
+ oos.Minute.ToString();
Instead of formatting the string manually, you should use:
oos.ToString("M/d/yyyy HH:mm");
Also, what do you mean by "would not accept a value"? Are you getting an exception? If so, what is the error message?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With