Wrong date output when extracting date from excel and pasting into word

Hi currently struggling with a school project hence, i decided to come onto the forum to seek help from the professionals pls help me out!!!

So my robot has to extract the date from excel and paste it into a word document. The thing is in the excel file the date has a formula eg. I have to get the date from Row A and B (both are dates) but the date in Row B has a formula where it has to minus 14 days from Row A. My date in Row A would be 30 Jun 2024 and with the formula it will be 16 Jun 2024 in Row B. However, when the date is extracted from the excel and pasted in the word doc, the output is 16 Dec 1899 instead of the date that i wanted which is 16 Jun 2024.

Has anyone encountered this issue before if not can anybody help me troubleshoot this? My date variables are saved as generic value in UiPath and in the excel file, i have converted Row A into text(edate) format. I didn’t convert Row B into text format as it gives me the same output as the above mentioned. Pls help me out with this issue!!!

@Cheryl_Chew

Welcome to the community

  1. Can you share the file here please
  2. Did you try reading excel with display value as the formatting in the use excel file /read range

Cheers

Hi @Cheryl_Chew

->Just read the excel file in read only mode and store the date value in string variable like Str_date= correntRow(“ColumnName”).tostring
->And convert the extracted date from Excel into a DateTime object in UiPath. This way
DateTime.ParseExact(Str_date, “dd MMM yyyy”, CultureInfo.InvariantCulture);

Thank you

Hi @Cheryl_Chew

Read the excel by using read range activity
Use for each loop

originalDate = DateTime.FromOADate(Double.Parse(row("DateInRowA").ToString()))
calculatedDate = DateTime.FromOADate(Double.Parse(row("DateInRowB").ToString()))

Hope this helps