UiPAth swaps day with Month

Hey guys,

I have that strange problem from couple of days. When I read/write in UIPath Studio xls to xlsx, the columns with dates swap the dd with MM when dd is <= 12. If it is above 12 it keeps the format I want dd/MM/yyyy.

Have you ever encountered that problem? And how did you fix it.

Regards,
Phoenix

if im not wrong your system date is in MM/dd/yyyy format change it to dd/MM/yyyy then it will work.
if did not then try this
DateTime.ParseExact(Date_String,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)
if still facing problems you can post anytime.

Hi @Phoenixxx,
Was that before? Any MS Office update?
XLSX are base on XML format and maybe during conversion something is changing.

Hey @ashley11

How should I use you method. For each thrue every cell?

No, there were no updates recently.

@Phoenixxx

  1. you must have used read range activity first
  2. now inside the excel application scope you must have used write cell activity
  3. before using the write cell activity take an assign activity
  4. coverted_Date = DateTime.ParseExact(row(“date_column_name”),“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)(Note: the variable type of coverted_Date should be System.Datetime )
  5. now use write cell activity and the value shoild be coverted_Date

I did want you said, but it gives me that error. Hmm?

i thought u have used write cell activity

  1. use read range activity
  2. use for each row activity inside for each activity just use assign activity
  3. row(“Date_col_Name”) = DateTime.ParseExact(row(“date_column_name”),“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)
  4. outside the for each activity use write range activity. the data table for the input parameter will be the out put of the read range activity

Hey @ashley11

Thanks for the guidance. I did everything you said, but it still says: "disallows implicit conversion from ‘Object’ to ‘String’. I think I am missing something fundamental.

row(“Date_col_Name”) = DateTime.ParseExact(row(“date_column_name”).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

sorry add .ToString

1 Like

And For Each is inside the For Each Row or it is the other way around?

@phoenixxx In Addition to the .ToString part, if you are sometimes getting dates in MM/dd/yyyy format and sometimes in dd/MM/yyyy format, you should provide both formats in a string array. So it’d be something like this:

row(“Date_col_Name”) = DateTime.ParseExact(row(“date_column_name”).ToString,{“dd/MM/yyyy”,"MM/dd/yyyy"},System.Globalization.CultureInfo.InvariantCulture)

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