How to change the date formats

How to change the date format like 31.05.2023 to May’2023?
How to change the format of dates like our requirement?

Hi @anjani_priya

You can try this

Assign activity:
originalDate = DateTime.ParseExact(yourDateString, “dd.MM.yyyy”, CultureInfo.InvariantCulture)

Assign activity:
formattedDate = originalDate.ToString(“MMM’yyyy”)

Write Line activity:
"Formatted Date: " + formattedDate

Try with expression in assign activity

stroutput = DateTime.ParseExact(strinput.ToString.SubString(0,10), “dd.MM.yyyy”, CultureInfo.InvariantCulture).ToString(“MMM’yyyy”)

Have a view in this for all Datetime operations

Cheers @anjani_priya

where should i give the input

1 Like

Where should i pass my value?

In assign activity @anjani_priya
Strinput is the variable with which u can pass the input value

1 Like


you need to give your date in “yourDateString” Variable from above example

Hi @anjani_priya
Remove the double quotes and give it again. It will solve the error.


Try to type in again
It would work @anjani_priya

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