Convert 2 extracted values in a datetime variable and compare it with system month

Hi all,

Please help me find a solution. I need to extract from the bellow table (first column is Month and the second is Year) the variables (I use get text activity).

After that I need somehow to convert the both variables in a date format and use it in a if variable where I need to compare with the system month and year and if the difference is bigger then 2.

My problems are:
Step 1:

  • build a variable (BuildDateVar) in a assign activity: MonthExtracted.tostring+“/”+“01”+“/”+YearExtracted.toString

  • Use a if activity with the follwing command:
    DateTime.ParseExact(BuildDateVar,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture) > Today.AddDays(-60)

My Problems are: Error date no recognized (BuildDateVar).

  • I compare the days and not the month (please help me here).

Best regards,
Paul

image

@paul.baltag1 DateTime.ParseExact(BuildDateVar,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).subtract(datetime.now) >2

Hello,
there is simpler way to create datetime variable:

BuildDateVar = new Date(Cint(YearExtracted),Cint(MonthExtracted),1)

To check if there is at least 2 month difference:

(Now.Year*12 + Now.Month - BuildDateVar.Year*12 - BuildDateVar.Month > 2) Or
(Now.Year*12 + Now.Month - BuildDateVar.Year*12 - BuildDateVar.Month = 2) And Now.Day>BuildDateVar.Day

Do you have any idea what type of datetime variable should be BuildDateVar ?

System.DateTime

Hello @paul.baltag1

Have you tried with the Modify date activity?

Thanks

HI @paul.baltag1

try with this expression

DateTime.ParseExact(BuildDateVar,{"MM/dd/yyyy","M/dd/yyyy"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None) > Today.AddDays(-60)

Regards
Sudharsan

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