How to change different date formats in a column

If there are different month with year in a column how to change them to the constant format.
how to makes changes for the entire column

Hi @anjani_priya

Can you share the sample input of the format that you have in Excel so that I can help you with the syntax.

Regards

@anjani_priya

If you need it on excel …then you can use format cells activity and select custom and give any date format you need

Cheers

Book1.xlsx (15.3 KB)
in input,input2,input3 sheets
the months Apr’22 should replace with 30/4/2023
may’22 should replace with 31/5/2023
like wise in three sheets the month should replace with date format (end date of month)

@anjani_priya

=> Read Range all three sheets are store it in three different DataTables.
=> Use For Each Row in Data Table to iterate through each row and in assign activity use below syntax

Str_date= DateTime.ParseExact(CurrentRow("month").ToString,"MMM'yy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Str_date is of DataType System.String.
You can use the same syntax for all three sheets by using For Each Row in Data Table for each Data Table.
Hope it helps!!

Book1.xlsx (16.3 KB)


It didnt changed

Hi @anjani_priya

Try the below code it is working

DateTime.ParseExact(CurrentRow("Month").ToString.Replace("'", ""), "MMMyy", System.Globalization.CultureInfo.CurrentCulture).AddMonths(1).AddDays(-1).ToString("dd/MM/yyyy")

O/P:

Hope this helps!!

If i want for multiple sheets how to do?

@anjani_priya

looks like the cell does not contain a date at all…

you can do this…read the data into datatable and then use the below in ivoke code by sending dt as in/out argument

dt.AsEnumerable.ToList.ForEach(sub(r) r("month") = DateTime.DaysInMonth(DateTime.ParseExact(r("month").ToString, "MMM'yy", CultureInfo.CurrentCulture).Year,DateTime.ParseExact(r("month").ToString, "MMM'yy", CultureInfo.CurrentCulture).Month).ToString + DateTime.ParseExact(r("month").ToString, "MMM'yy", CultureInfo.CurrentCulture).ToString("/MM/yyyy"))

then write the data back to excel

cheers

@anjani_priya

Try like this

BlankProcess14.zip (105.3 KB)

Book1 (9).xlsx (15.2 KB)

Hope this helps!!


error

what is the code in assign activity?
in your given input file and screenshot doesnot match

@anjani_priya

Please check on this xaml

There are 2 xamls in this file Sequence xaml is your code. Please ignore main xaml

Capture29
like this,the date format should be there
cell should show apr’23 but the value inside should be date format
how to change like this?

how to do?this method

Capture29
this is the method i want

@anjani_priya

did you try what we gave…as per screenshot the date is not last date of month…

cheers

@anjani_priya

you can try this once

Sequence2.xaml (8.2 KB)

@anjani_priya

The datatype shpuld be datatable not string

Cheers