How to Convert 09/26/2022 00:00:00 to 26-SEP-2022

Anyone please do suggest a expression

HI @Gopikrishna_S

You can try with this expression

DateTime.ParseExact(StringInput.ToString,"MM/dd/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yyyy")

Regards
Gokul

HI @Gopikrishna_S

Check out the another expression

DateTime.ParseExact(StringInput.ToString,"MM/dd/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yyyy")

image

Hi @Gopikrishna_S

It will get the Month in the Upper case

DateTime.ParseExact("09/26/2022 00:00:00","MM/dd/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-yyyy").ToUpper

image

its working. I have another Doubt in 09/26/2022 00:00:00 if i want to remove this 00:00:00 time stamp what expression I need to give

Hi @Gopikrishna_S

You can try with Regex Expression

System.Text.RegularExpressions.Regex.Replace(YourString,"\b\d{2}:\d{2}:\d{2}\b","").Tostring

image

Regards
Gokul

Thanks Gokul, I have got the Required Output :slightly_smiling_face:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.