Convert date to desired format

Hi Everyone,

I am trying to convert a date 20230919 to the desired format

Appreciate if helped with a syntax

Hi @Tanu_G

Check this out

Datetimevar= DateTime.ParseExact(“20230919”,“yyyyMMdd”,System.Globalization.CultureInfo.InvariantCulture). ToString(“MM/yyyy/dd”)

Hope this helps

1 Like

Thanks @nikhil.girish

Will try this now

if you might have different input date formats, I recommend always using parse exact, but providing various date patterns in an input array.

var_datetime = DateTime.ParseExact(Strinput.ToString, arr_formats, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None)

arr_formats = {“yyyyMMdd”, “MM/dd/yyyy”, “dd/yy”}

I hope it helped you


Thanks @andreus91 this looks cool too!

But current requirement is only for the above format
But definitely I will be needing this in future


1 Like

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