I have one column with dates in the dd.MM.yyyy format, I have to take each row and subtract 4 from the day and paste it in the excel cell. For example 23.05.2019 so I have to 23-4=19 write it to the excel as 19.05.2019. I’ve tried to save in the endDate variable which is string type in the for loop the dates and in the newDate variable(string type) I did the following newDate=Datetime.ParseExact(endDate,“dd.MM.yyyy”,system.Globalization.CultureInfo.InvariantCulture).AddMonths(-4).ToString, my endDate=CurrentRow.Item(“Date”).ToString, but it shows the error as below
Can someone help me how to do it?
@Symbat_Almakhan it’s not add months ,it should be adddays in your code.Try this