How to get exact date format ("MM/dd/yyyy") from the excel

Hi,

In the excel date format will be MM/dd/yyyy. how can i achieve below?

Excel Date2 Actual Result Expected Result
11-04-2022 04-11-2022 11-04-2022
09-03-2022 03-09-2022 09-03-2022
04-24-2022 04-24-2022 04-24-2022
12-25-2023 12-25-2023 12-25-2023

Thanks
Uma

Hi @Umadevi_Sanjeevi

How about this expression

DateTime.ParseExact(CurrentRow("Column Name").ToString.Trim,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")

Note : dd-MM-yyyy -> Based on excel date fomat

Or

You can try to change the format of the column

  1. Excel process scope activity

  2. Use excel file activity

  3. Format cell activity

image

Or

Try with BalaReva package

Regards
Gokul

1 Like

Hi Gokul,

I’m getting below error.

Error : Assign: String was not recognized as a valid DateTime.

Thanks

Hey!

Try this:

  1. Read excel using read range output as → Dt_Out
  2. Take one for each row in data table activity and pass the Dt_Out

Now take one assign activity and create one string variable called InputDate and pass the expression like this…

Datetime.ParseExact(CurrentRow("ColumnName").ToString, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")

Regards,
NaNi

Can you share the sample excel file @Umadevi_Sanjeevi

I have update my previous post check it out

Hi Thiru,

Getting this Error : Assign: String was not recognized as a valid DateTime.

Thanks

Hi Gokul,

Tried Change format activity. But why we need to change date format. Already the date format will be MM-dd-yyyy.

Bad luck facing same issue.

Sample Data below:

Date2 Actual Result Expected Result
11-04-2022 04-11-2022 11-04-2022
09-03-2022 03-09-2022 09-03-2022
04-24-2022 04-24-2022 04-24-2022
12-25-2023 12-25-2023 12-25-2023

Thanks

Share the excel file @Umadevi_Sanjeevi

While seeing the excel it show like MM-dd-yyyy format. While automating it will give different format.

What was the error while changing the format?

Regards
Gokul

Hello @Umadevi_Sanjeevi

If you need to get the dates from excel in the format dd-mm-yyyy, then you can use Modify Date activity.

Thanks