Add one year to string

Hi,

I have a string 01.01.2019 and I need to add here one year. I cannot convert this string to date and then add :frowning: Thanks for help

Hi @Marek_Matuszak, kindly check this code to add one year to given date in string

given_date = "01.01.2019"
 next_date = DateTime.ParseExact(given_date, "dd.mm.yyyy", System.Globalization.CultureInfo.InvariantCulture).AddYears(1).ToString("dd.mm.yyyy") 

Output is : image

Hope it helps you

Mark it as solution if you got it

Regards
Nived N
Happy Automation

Hi @Marek_Matuszak,

Simplest thing you can do is :
String = “01.01.2019”
Cdate(String).AddYears(1).toString("dd.mm.yyyy")

Cheers

1 Like