How to change the date formats

1 Like

Hi you can try this way

DateTime.ParseExact("31.05.2023","dd.MM.yyyy",System.Globalization.CultureInfo.CurrentUICulture).ToString("MMM yyyy")


follow this steps :slight_smile:


if the date is like 31 december 2021 or any other format how to change that to mm’yyyy format?

Pass them in double quotes @anjani_priya


If that’s the case the format changes accordingly like this

dd MMMM yyyy - we need pass accordingly

stroutput = DateTime.ParseExact(strinput.ToString, “dd MMMM yyyy”, CultureInfo.InvariantCulture).ToString(“MMM’yyyy”)

I would recommend to have a view on this to know all the date format


If the formats are changing dynamically how to declare?

1 Like

Date format has to be standard and defined
we need to make it robust with stable dateformat
which is actually a good practice. Ask the user or system that generates the report to create the file with same dateformat

Or atleast if u know the possible different date format
Then you can pass it as array
It’s in above thread which I shared

Convert a String of multiple possible date formats to a Datetime variable

Say you have a date string which can be of different formats for each time it is being used like
“dd/MM/yyyy”, “MM/dd/yyyy”, “dd/yy”

Then have all these possible formats in a array variable named arr_formats

Like this

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

Then to convert that string as Datetime

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


Try this way

str= "31 december 2021"
CDate(str).AddMonths(0).AddDays(-1).toString("MMM yyyy")


Hope this Clarifies

HI @anjani_priya

you can try this it will work sure even the date formats are different also

Xaml : - (2.4 KB)

for reference you can see input and ouput :slight_smile:



output :

how to declare this month format in array?
and how to change 31st may 2022 format in mmyyyy

Hi @anjani_priya

In the array declare as MMM'yy

DateTime.ParseExact("31st may 2022","d MMMM yyyy",System.Globalization.CultureInfor.InvariantCulture).ToString("MMyyyy")


How to set jan’2023 format in an array?

How to set jan’2023 fromat?

Hi @anjani_priya

you can try out this xaml even the your input dates have st or nd or rd or th it will work anyt type of date format

Xaml : - (2.7 KB)

for reference you can see the input and out put

input : -

OutPut : -


I want month and year
In input array how to set jan’2023 format?

if you need to values to array you can try this way

arr = {"jan’2023"}

Note : arr variable type is system.string[]



if you need to add more to arr variable then add like this

arr = {"jan’2023",dfsdfds,sdfsdf,sdfsdf,sddfsdf}


cant we add in mmyyyy format?