Convert date time

not able to convert variable into date time and add days

Cannot evaluate ‘(Convert.ToDateTime(pdf_date.ToString))’ at current context.

I tried to check the value of pdf_date and pdf_date.ToString in immediate window
it coming
but conversion throws error
pdf_date is “16.5.2021”

also after that I need to add days

(Convert.ToDateTime(pdf_date.ToString)).AddDays(Cint(Regex.Split(var2,"-")(1))*7).ToShortDateString ---- this gives the error as
Assign: String was not recognized as a valid DateTime.

Convert.ToDateTime is expecting input in US format i.e., MM.dd.yyy format. So it works for 5.16.2021. It doesn’t work for 16.5.2021 because month value cannot be greater than 12

so shall I first convert into US format ??
(pdf_date.ToString).ToShortDateString(“MM/dd/yyyy”) doesnt work

and this also doesnt work
But Cdate is also not working

since add days need input in date time format

what else can i do ?

@Sakshi_Jain - you need to use datetime.parseexact to convert from dd.Mm.yyyy to your desire format first. And then do the manipulation.

i think use Convert.ToDateTime(Varibale)

variable type is datetime


New DateTime(DateTime.Today.Year,Birthaday.Month,Birthaday.Day)

Chethan P



Can you share your variables section and related part of the workflow screenshots?

Sure I can , but here I can using only one variable Date1
Date1 is string type
and after addition also i am trying to update in string variable

the same work when date is like US format like MM.dd.yyyy
but actually date is in dd.MM.yyyy format , so when date value to larger than 12 or max month then it throws error

@Sakshi_Jain - 16.5.2021 is dd.M.yyyy not dd.MM.yyyy

16.05.2021 is dd.MM.yyyy

M means without leading zeros single digit Months
MM means with leading zeros for single digit months

@Sakshi_Jain - Please check this…