Hi! I am having trouble converting a string extracted from a web page that has the following pattern “dd.mm.yyyy”, to a DateTime value. I have to add 30 days to that date and then insert it in the same web page with string format following the same pattern “dd.mm.yyyy”.
This is what I did so far but I can not get the new DateTime value into the format string to insert it again in the web page:
Get full text → output: MyDate in string format
Assign → NewMyDate in DateTime format = Convert.ToDateTime(DateTime.ParseExact(MyDate,“dd.mm.yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“mm.dd.yyyy”))
Assign → NewMyDate = NewMyDate.AddMOnths(1)
Up to here everything goes fine but when I try to paste that value in the string format following “dd.mm.yyyy” pattern it fails:
Type Into → NewMyDate.ToString(“dd.mm.yyyy”,System.Globalization.CultureInfo.InvariantCulture)
This s fine [quote=“FlorSiri, post:1, topic:157188”]
Get full text → output: MyDate in string format
[/quote]
Then while doing this
No need to convert to DateTime just this is enough
It’s MM which denotes month as mm denotes minutes NeeMyDate = DateTime.ParseExact(MyDate,“dd.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture)
Then this is fine as well NewMyDate = NewMyDate.AddMonths(1)
Finally in type into be like this NewMyDate.ToString(“dd.MM.yyyy”)
Kindly try this and let know for any queries or clarification
Cheers @FlorSiri