Subtract a day from a specific date in excel

Hi all,

i have a date column in excel that I am populating todays date+certain number of days. this is working fine.
dateTime.now. ddDays(Convert.ToInt32(row(“NumberdaystoCurtail”).ToString)).ToString(“MM/dd/yyyy”)

I need to subtract one day from the resulting date column. i am using the formula below

*** DateAdd(“d”,-1,row)**

and i am getting an error. “argument date value cannot be converted to date type”. can anyone advise where the mistake is

You are trying to add days to a string, inside your second for each row… And why do you have 2 for each rows of the same data table?

i dont have to have two for each rows. just kept them separate for testing purposes so i can comment it out.
Could you indicate the correct syntax for the second for each?

row("CurtailDate")=dateTime.now.addDays(CDbl(row("NumberdaystoCurtail")))

this part i already have and it works. (the first “for each” above - the curtail date column is equal to todays Date+ no. of days to curtail )

the second part is - with the date that is now generated under curtail date column, i need to subtract 1 day.

row(“CurtailDate”)=dateTime.now.addDays(CDbl(row(“NumberdaystoCurtail”))-1)

oh i see. you are combining both the steps. working fine except the time stamp. how do i eliminate the time stamp?

The only way to do that is to not use Date type or to format excel to not show it…

thank you very much. appreciate your help

1 Like

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