Add one year to a varible

Hi Team,

I have a cell activity that reads from an Excel file a date and I want to add a month or year to this date so how can I do that

@omar_ismail

Please put an input and output

For adding a month:
yourDateVariable = yourDateVariable.AddMonths(1)

For adding a year:
yourDateVariable = yourDateVariable.AddYears(1)

it’s giving me an error (Add month is not a member in integer)

Hi @omar_ismail

If you want to Add Year:

Year = DateTime..ParseExact(Input,"MM/dd/yyyy",System.GLobalization.CultureInfo.InvariantCulture).AddYears(1).ToString("MM/dd/yyyy")

If you want to Add Month:

Month = DateTime..ParseExact(Input,"MM/dd/yyyy",System.GLobalization.CultureInfo.InvariantCulture).AddMonths(1).ToString("MM/dd/yyyy")

Regards

Hi @omar_ismail

What is the Output variable type of Read Cell activity, can you specify?

Regards


string

Hi @omar_ismail

Sorry it was my bad that I inserted two dots:

Check this:
If you want to Add Year:

Year = DateTime.ParseExact(Input,"MM/dd/yyyy",System.GLobalization.CultureInfo.InvariantCulture).AddYears(1).ToString("MM/dd/yyyy")

If you want to Add Month:

Month = DateTime.ParseExact(Input,"MM/dd/yyyy",System.GLobalization.CultureInfo.InvariantCulture).AddMonths(1).ToString("MM/dd/yyyy")

Change the format of date according to yours
Regards

Hi @omar_ismail

Or you can even try this way:

Regards


same error

Hi @omar_ismail

Please pass your Input variable that is OldDate instead of Input.

Regards

@omar_ismail

Please put the format of your date if it is “dd/MM/yyyy” or “MM/dd/yyyy”

Year=DateTime.ParseExact(OldDate,"Your Format",System.Globalization.Culturalinfo.InvarientCulture).AddYears(1).ToString("MM/dd/yyyy")
Month=DateTime.ParseExact(OldDate,"YourFormat",System.GLobalization.CultureInfo.InvariantCulture).AddMonths(1).ToString("MM/dd/yyyy")


same issue

@omar_ismail

Please put your excel screenshot

Hi @omar_ismail

Please Type CDate(OldDate) there

Please refer the screenshot. The same I have mentioned in that too @omar_ismail

Regards

@omar_ismail

In imports panel import System.Globalization

And also CultureInfo “I” Should be Capital

Hi @omar_ismail

Input:
image

Workflow:

Output:

Xaml:
Sequence36.xaml (13.4 KB)

Please check the workflow and replicate your process.

Regards

@omar_ismail

Is the error gone if it is not gone then cut the expression and simply paste the expression

DateTime.ParseExact(OldDate,"MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).AddYears(1).ToString("MM/dd/yyyy")

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