Convert date format-month

Guys, Format is not getting changed while writing back to excel

Ok let me tell the scenario,
I am doing data scraping-obtained data table
using for each row
row("date)=Datetime.ParseExact(row.item("date),“dd-MMM-yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)

after for ends

same dt is tracked to excel

@KarthikBallary, Which DataType are you using while building table. I am assuming that you are using Write Range activity to write back to excel, so you must be supplying DataTable to that activity. If you date column is type of String then it will export data as you expected. If you are using DateTime then format will change as you demonstrated in above post.

Yes I am using write range activity

What is DataType of your column?

how to check datatype of a column

Ya data type is of String

Just for testing purpose add Write Line Activity with value: dataTableName.Columns(“Date”).DataType.ToString

Where “Date” is your column name.

it is of String

@KarthikBallary Are you trying to Convert the Date Column in Datatable to another Format and Save the Format in that way ?

No converting the format to compare with other date in excel.
I am tracking dt to to excel

In that case, you may want to remove formatting in your excel if any. Just clear format for that particular column and try it again. I try it and it is working for me. I believe, issue is not with UiPath but issue is with Excel. To ensure you can write DataTable to new Excel file. Just use Write Range Activity and create new file and see outcome.

how to format in uipath

row.item(“date”)=DateTime.ParseExact(row.Item(“date”).ToString,“yyyy-MM-dd”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

not working throwing error
not of correct format

@KarthikBallary

First you need to define proper column format in Excel and then write into Excel file. Once you changed the format then only it should work.

Ok every time I run, I have to clear the old Data?
How do I delete that via Uipath.

Before writing to excel it is throwing error. Date is of not proper format

ok a row contains date format and somewhere it appears text. Hence not taking assign activity in for each

1 Like

Hi @KarthikBallary,

using the below activity, It will convert the data table column to the DateTime column. No need to use the for each loop.

Regards
Balamurugan.S

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