V Vai2000 Mar 2, 2005 #1 Hi All, I am getting date in yyyyMMdd format.How do I parse it? string s="20050302"; need to convert this to DateTime object TIA
Hi All, I am getting date in yyyyMMdd format.How do I parse it? string s="20050302"; need to convert this to DateTime object TIA
J Jon Skeet [C# MVP] Mar 2, 2005 #2 Vai2000 said: Hi All, I am getting date in yyyyMMdd format.How do I parse it? string s="20050302"; need to convert this to DateTime object Click to expand... Use DateTime.ParseExact: DateTime dt = DateTime.ParseExact (s, "yyyyMMdd", CultureInfo.InvariantCulture);
Vai2000 said: Hi All, I am getting date in yyyyMMdd format.How do I parse it? string s="20050302"; need to convert this to DateTime object Click to expand... Use DateTime.ParseExact: DateTime dt = DateTime.ParseExact (s, "yyyyMMdd", CultureInfo.InvariantCulture);
V Vai2000 Mar 2, 2005 #4 Thanks ya all Tim Wilson said: Try the DateTime.ParseExact() method. Click to expand...
S szeying.tan Mar 2, 2005 #5 try this: DateTimeFormatInfo myDTFI = new DateTimeFormatInfo(); myDTFI.DateSeparator = string.Empty; myDTFI.FullDateTimePattern = mask; string s = "20050302"; DateTime d = DateTime.ParseExact(s, myDTFI);
try this: DateTimeFormatInfo myDTFI = new DateTimeFormatInfo(); myDTFI.DateSeparator = string.Empty; myDTFI.FullDateTimePattern = mask; string s = "20050302"; DateTime d = DateTime.ParseExact(s, myDTFI);