How to add days to a date when no of days is stored in config

Hi I want to add 30 days to a certain date ,
Currently I am doing as below -
Datetime.ParseExact((in_Config(“BNY_Last_Updated_Date”).ToString),“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(”+"+“in_Config(“Password Validity Days”).ToString”)

but its giving error.Please help here

Hi, store the json string in int variable using: CInt(in_Config(“Password Validity Days”).ToString) and then use inside AddDays().

Hi @gokul1904 ,

Could you try with the below :

Datetime.ParseExact(in_Config("BNY_Last_Updated_Date").ToString,"MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).AddDays(Cint(in_Config("Password Validity Days").ToString))

If the above still results in an error, Share the error message as well

1 Like

Hi @gokul1904

Datetime.ParseExact(in_Config("BNY_Last_Updated_Date").ToString, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).AddDays(Cint(in_Config("Password Validity Days").ToString)).Tostring("dd-MM-yyyy")

Hi @gokul1904

After AddDays You need to covert the string into Int

How about this expression?

Datetime.ParseExact(in_Config("BNY_Last_Updated_Date").ToString,"MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).AddDays(Cint(in_Config("Password Validity Days").ToString)).Tostring("dd-MM-yyyy")

Regards
Gokul

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