converting string to date format like dd-mon-yyyy

Viewed 119

I have date value as string like 20200731 i have used to Below Code to Parse it with Exact date

Date.ParseExact(filenames.Substring(39,8).ToString(),"yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo)

Output of above Expression is 07/31/2020 00:00:00 , However i want to get output like 31-JUL-2020

1 Answers

Do you mean something like this?

Console.WriteLine(Strings.Format(Date.ParseExact("20200731", "yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo), "dd-MMM-yyyy").ToUpper)
Related