How to subtract days from a date(string variable)

Hi,
I have date in string variable(11.01.2020), and I need subtract day from that date.

variable(String)=DateTime.ParseExact(variable,“dd-MM-yyyy”,Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“dd-MM-yyyy”)

I do it like this but now is error “String was not recognised as a valid DateTime”.

Please help, ty in advance

1 Like

@JOHOHO Try this :
variable (String)=DateTime.ParseExact( variable ,“dd.MM.yyyy”,Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“dd-MM-yyyy”)

3 Likes

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