Check dates using if condition

My query has a column expiry_ date which fetches me all the expiry dates of a subscription which will expire in 30 days from today.

Now using this expiry_date I have to check which expiry dates have 1 day left for expiration , also dates which have 3 and 7 days left for expiration.

How can I filter this using if.?

what format is your expiry date? @automated

Hello @automated , welcome to UiPath Forum.

Assign YourDateFormat = “dd-MM-yyyy”
(you can change it as per your date format present in excel.

To get the records which have 1 day left for expiry :

Expiry_OnedayDt = (From row In InputDt where (Datetime.ParseExact(row(“Exp_Date”).ToString,YourDateFormat,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”).Equals(Now.AddDays(1).ToString(“dd-MM-yyyy”))) Select row).CopyToDataTable()

To get the records which have 3 day left for expiry :

Expiry_ThreedayDt = (From row In InputDt where (Datetime.ParseExact(row(“Exp_Date”).ToString,YourDateFormat,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”).Equals(Now.AddDays(3).ToString(“dd-MM-yyyy”))) Select row).CopyToDataTable()

To get the records which have 7 day left for expiry :

Expiry_SevendayDt = (From row In InputDt where (Datetime.ParseExact(row(“Exp_Date”).ToString,YourDateFormat,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”).Equals(Now.AddDays(7).ToString(“dd-MM-yyyy”))) Select row).CopyToDataTable()


Thanks for your answer.
Actually, I already have a column that gives expiry days left for subscription, I have to loop through that column checking for which customers have 3, 5, and 7 days left. And then need to send SMS.
My IF condition is not working correctly as it should be.

days_to_expire = CurrentRow.Item(0).ToString

days_to_expire > = 1 AND days_to_expire <=3 ( for customers who have 3 days left).
Is this the right thing to do.?

Hi @automated ,

Make sure to use Integer type variable to assign the value. That would need to correct your expression to the below :

days_to_expire = Cint(CurrentRow.Item(0).ToString)

Here, days_to_expire variable should be of the type Integer.

The If Condition should work after this change if it was not done before.

But as per your condition, you would need to Check specific number of days 3, 5, 7.

So your condition should be in the below manner :

(days_to_expire = 3) or (days_to_expire = 5) or (days_to_expire = 7)

Let us know if you are still not able to get the flow working in the right way.

Hi, Thank you for your response.
There is a new change as follows.

When the SMS is send where only three days are left to expiry ,
after that a second notification is to be send for renewal after 5 days of previous SMS send( which here is sent when 3 days were left to expiry). So if sms was sent on 1/jan/2007 as three days left to expiry the other SMS has to be sent on 7/jan/2007.

How can it be achieved.