Adeel Aslam
Adeel Aslam

Reputation: 1294

converting string to date format like dd-mon-yyyy

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

Upvotes: 2

Views: 298

Answers (1)

G3nt_M3caj
G3nt_M3caj

Reputation: 2705

Do you mean something like this?

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

Upvotes: 2

Related Questions