How to change the excel column (Due Date) format from MM/dd/yyyy to yyyy/MM/dd

Hi Guys I am trying to change the format excel column (Due Date) format from MM/dd/yyyy to yyyy/MM/dd without the time span?

Due date
12/13/2021 00:00:00
10/05/2023 00:00:00
10/03/2023 00:00:00
02/06/2023 00:00:00
11/03/2023 00:00:00
11/03/2023 00:00:00
08/21/2023 00:00:00
09/01/2023 00:00:00
09/08/2023 00:00:00
09/08/2023 00:00:00
09/08/2023 00:00:00
08/04/2023 00:00:00
09/19/2023 00:00:00
09/15/2023 00:00:00
09/15/2023 00:00:00
08/18/2023 00:00:00

Hi @ahmed4566

Try the Format Cells Activity

Hi @ahmed4566

How about this

row(0) = DateTime.ParseExact(row(0).ToString, “MM/dd/yyyy HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy/MM/dd”)

Hi @ahmed4566

Try using Format Cells activity
Or
→ Use Read Range Workbook to read the excel and store the output in a datatable say dt.
→ Use For Each row in DataTable to iterate through dt.
→ inside the loop use below below syntax in assign activity

CurrentRow("Due Date") = DateTime.ParseExact(CurrentRow("Due Date").ToString, "MM/dd/yyyy HH:mm:s", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy/MM/dd")

→ Use to Write Range Workbook to write he data back to excel.

Hope it helps!!

@ahmed4566

If it is needed on excel then use format cells activity

If you need it in your code o use some there then use the following in Invoke code with dt as in/out argument

Dt.AsEnumerable.ToList.ForEach(Sub(r) r("ColumnName") = Cdate(r("ColumnName").ToString).ToString("yyyy/MM/dd"))

This will convert all values in given column to the required destination format

Cheers

Hi @ahmed4566,

If you want activity based, try this workflow

Code
CDate(CurrentRow("Date").ToString).ToString("yyyy/MM/dd")

Xaml
Date.xaml (7.6 KB)

Thanks,

Thank you Parvathy,Its working fine,

1 Like

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