Problem while Parsing DateTime.
-
Hi, I am collecting OS info using Win32_OperatingSystem(WMI). its one property(InstallDate) which gives Installation Date of the OS, but datetime is in 20091117110355.375000+330 format. I want to convert this into actual DateTime format. Thanks, Sunil G.
-
Hi, I am collecting OS info using Win32_OperatingSystem(WMI). its one property(InstallDate) which gives Installation Date of the OS, but datetime is in 20091117110355.375000+330 format. I want to convert this into actual DateTime format. Thanks, Sunil G.
Try this...
DateTime GetMeTheDateAndTime(string s)
{
return DateTime.ParseExact(s.Substring(0, 14), "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvarientCulture);
}...you may wan't to apply some validation thou
Life goes very fast. Tomorrow, today is already yesterday.
-
Hi, I am collecting OS info using Win32_OperatingSystem(WMI). its one property(InstallDate) which gives Installation Date of the OS, but datetime is in 20091117110355.375000+330 format. I want to convert this into actual DateTime format. Thanks, Sunil G.
This works for sure, there may be something more compact:
string s="20091117110355.375000+330";
DateTime.ParseExact(s.Substring(0,14), "yyyyMMddHHmmss",null);:)
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Try this...
DateTime GetMeTheDateAndTime(string s)
{
return DateTime.ParseExact(s.Substring(0, 14), "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvarientCulture);
}...you may wan't to apply some validation thou
Life goes very fast. Tomorrow, today is already yesterday.
-
Hi, I am collecting OS info using Win32_OperatingSystem(WMI). its one property(InstallDate) which gives Installation Date of the OS, but datetime is in 20091117110355.375000+330 format. I want to convert this into actual DateTime format. Thanks, Sunil G.