Change Date Format To Another Format

Hi Everyone

I want to convert the String 1 which is date to another string which will also be date but in another date format.
Str1= 03-05-2024
Expected= Feb03, 2024

Hi @SP_Bot

You can use the below dateTime Expression,

DateTime.ParseExact(Str1, ("MM/dd/yyyy"), System.Globalization.CultureInfo.InvariantCulture).toString("MMMdd, yyyy")

Check the below image for better understanding,

Expression explanation -
DateTime.ParseExact(Pass Variable here, ("Present Format"),System.Globalization.CultureInfo.InvariantCulture).toString("Required format")

Hope it helps!!

2 Likes

Hi @SP_Bot

Try this :

DateTime.ParseExact(Str1,"MM-dd-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("MMMdd, yyyy")

Hope it will helps you :slight_smile:
Cheers!!

1 Like

I have Done some changes
Please have a look

Check- I have Modified

Hi @SP_Bot

Just FYI, there is another approach

Regards,

1 Like

Here is the modified one,

DateTime.ParseExact(Str1, ("MM-dd-yyyy"), System.Globalization.CultureInfo.InvariantCulture).toString("MMMdd, yyyy")

Check the below image for better understanding,

DateTime.ParseExact(Pass Variable here, (“Give Present Format
here”),System.Globalization.CultureInfo.InvariantCulture).toString(“Give Required format here”)

Hope you understand!!

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