I have a string containing value in the format of 11/22/2019 00:00:00
I want to store this in a DateTime column.
I have tried this:
DateTime date ;
DateTime dtVal;
// string abcd contains 11/22/2019 00:00:00
abcd = date.ToString("MM/dd/yyyy hh:mm:ss", CultureInfo.InvariantCulture);
if (DateTime.TryParseExact(abcd, "MM/dd/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None, out converteddate))
{
dtVal = converteddate; // I am getting 22/11/2019 12:00:00
}
I want the dtval value to hold the datetime value as - 11/22/2019 00:00:00
How to achieve this? Thanks
DateTime itself does not have its "natural" format, as John commented - it is internally "just a number";-). The ToString()
method depends on Culture
you set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.