I want to add 7 days to the existing date from excel

1.My excel consists of one column for Date/Time
2. The field is in the format of “01/26/2022 07:21:10”
3. I want to extract it from excel from each row and add 7 days to the above date and enter it in the application.

Please help me.

VAR.tostring(“dd/MM/yyyy hh:mm:ss”).AddDays(7)

Hi @shruthi_arali ,

As you get this value from each row of the Datatable.

We would need to Convert this value to DateTime first then Add 7 Days to it.

We could try the Following Approaches :

CDate("01/26/2022 07:21:10").AddDays(7).ToString("MM/dd/yyyy")

or

DateTime.ParseExact("01/26/2022 07:21:10","MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).AddDays(7).ToString("MM/dd/yyyy")

We could replace the input string date with the row(ColumnName).ToString

1 Like

you convert String to Date, add the 7 days, and finally re-convert to string if needed :slight_smile:

Date.Parse(“01/26/2022 07:21:10”).AddDays(7).toString(“yourFormatHere”)

“01/26/2022 07:21:10” → will be your row variable data.

image

Best Regards,

@supermanPunch
Thank you :slight_smile: , It worked.

@ignasi.peiris
Thank you :slight_smile: . This also worked…

1 Like

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