How to convert the date format in csv file to (dd/MM/yyyy)

Hello,

How to convert the date format in csv file to (dd/MM/yyyy).

The values below invoice date are dynamic.
image

Hi @Abhi4
=> Use Read CSV to read the file and store the output in a variable say dt_data
=> Use For Each Row in Data Table to iterate through the data table.
=> Use the Below Syntax in Assign Activity

CurrentRow("your column Name")= DateTime.ParseExact(CurrentRow("your column Name").ToString,"dd/MM/yyyy hh:mm",System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")

=> Use Write CSV to write it back to the file.

Hope it helps!!

@Parvathy ,

Thank you for the reply.

I want to convert all the values under Invoice Date excluding the first line

HI @Abhi4
Can you share the input csv file with dummy data so that I can get back to you with a solution.

Regards,

@Parvathy ,

I am not able to upload CSV file.

@Parvathy ,

Can you provide me with solution file.

I will help you with that @Abhi4

Regards,

Will there be data in the first cell every time . Please specify @Abhi4

Regards,

@Abhi4

after reading the csv file

assign activity

dt=dt.asenumerable.skip(2).copytodatatble

for each row in datatable activity

inside use this expression

or read the excel file range as from “A2:”

so that you will skip that first line

cheers

@Parvathy ,

Yes there will always data in first cell.

@Shiva_Nikhil ,

I want to convert the values under invoice date to (dd/MM/yyyy).
Whatever may be the date format,I have to convert to (dd/MM/yyyy).

Row number 6&7 are in different format.

image

@Abhi4

Use modern excel activities

use excel file activity

inside use format cells activity

pass your new date format which you want to get
cheers

@Shiva_Nikhil ,

I used format cell activity to convert the date , it worked and output file stored as excel file .xlsx.
I converted excel file to csv to upload csv format file in portal.

After converting the to csv file, date formats are changed in CSV file. I used Format cell activity for CSV file but not all the dates are changing to dd/MM/yyyy.
Can you help me with any other workaround?

Hi @Abhi4

Try this

DateTime.ParseExact(CurrentRow("Invoice Date").Tostring, {"dd/MM/yyyy hh:mm", "d/MM/yyyy h:mm"}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None)

Hi @Shiva_Nikhil

Check out he below zip file

DateTImer.zip (45.2 KB)

Hope it helps!!

@Parvathy ,

The given solution works but also i want to keep value first cell above Invoice Date.

@Parvathy ,

First Cell A1,is header date and I want to keep that value above Invoice date. or is it possible we can convert that value to in dd/MM/yyyy

@Abhi4

check this its working fine

dateformat.zip (9.8 KB)

in place of read rangeactivity you can place read csv file activity and follow all the steps

if any issue let me know

cheers

@Abhi4

Use a invoke code activity with dt as in/out datatable argument and add the read csv output datatable here

In the invoke code use this

Dt.AsEnumerable.Where(function(x,i) i>1).ToList.ForEach(Sub(r) r(0) = DateTime.ParseExact(r(0).ToString,"dd/MM/yyyy hh:mm",System.Globalization.CultureInfo.InvariantCulture)).ToString("MM/dd/yyyy")

Then write the data back to csv…

And while reading give no headers options

Cheers

@Shiva_Nikhil ,

only for the 3rd cell including header value is not getting changed.
image