Excel date data match with current date

Hello community,
I am newbie of UiPath and I need your help to complete my first RPA workflow.

I have an excel document. This document has two columns. First column has date information (MM-dd-yyyy), second one has some kind of information. All I want to do is, the RPA workflow check date information in the first table and if any row is existing in the column which is matching with current date, then send an email to someone with second column information.

I’ve already tried to do it with some If conditions but somehow I couldn’t be successful to match date information with current day.

Can someone help me to write right if condition for this?

Thanks in advance for your valuable help!!

Best,
Rihat

Buddy may i have that excel sample buddy @Sweetmisery
its easy we can do this
but would like to know the format of that date column…before starting
Cheers

1 Like

NewDtVariable = DTVariable.Select("[Column1_Name]=’"+DateTime.Now.ToString(“MM-dd-yyyy”)+"’").CopyToDataTable()

Result with >1 rows, data will be copied to NewDtVariable, send emails using For-each-row loop

Result with 0 rows, the syntax will not copy rows to datatble, use an IF condition with DTVariable.Select("[Column1_Name]=’"+DateTime.Now.ToString(“MM-dd-yyyy”)+"’").ToArray().Count>0

I like this, when you call Buddy, everyone in forum :slight_smile: .

1 Like

hello,
I am unable to upload any file due to I am newbie.

Here is screenshots what I am trying to do:

  1. The excel file:

    Column Schedule: Date information. Format: (MM-dd-yyyy)
    Column Message: Message information that I want to send someone on the current date.

My Workflow:
RPA-1

And above is first part of my code.

Thanks.

RPA-2
and this is last part of the code.

thanks.

Buddy @Sweetmisery
you were almost right. need to make small changes with if condition

Datetime.Parseexact(row(“Schedule”).ToString.Substring(0,10),“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”).Equals(now.ToString("dd/MM/yyyy)

then inside the send outlook mail activity you can include the row(“Message”).ToString
either to body or the subject buddy as you wish

Kindly try this and let know buddy whether it worked or not
Cheers…
if any error occured with string format conversion to datetime, kindly use a write line to check how the date text is getting printed in which format after obtaining from excel, based on that we can the format in the if condition buddy
@Sweetmisery

1 Like

Hello Thanks for quick reply!!!
Here is its print result:
result-printout

Once I type your code it gives following issue:
error

What could be reason for having this issue?

Thanks!!!

1 Like

Fine buddy @Sweetmisery

use this in your if condition buddy
Datetime.Parseexact(row(“Schedule”).ToString.Substring(0,10),“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”).Equals(now.ToString("dd/MM/yyyy))

you have - instead of /
thats why showing error buddy
try the above highlighted and that would work for sure buddy
Cheers @Sweetmisery

1 Like

Hey @Palaniyappan.

This is working Correctly.But If My Reqirement is only match Between Current system’s date & month to the schedule’s date & month only Not The Year.Can You Please Help me.

Thanks

Hi
Welcome to uipath community
If the schedule_date is 20-12 stores in a string variable named in_date

And if we need to compare this with the system DateTime
Then in if condition
DateTime.ParseExact(in_date,”dd-MM”,System.Globalization.CultureInfo.InvariantCulture) > DateTime.Now

Hope this would help you
Cheers @omprasad

1 Like

Thanks For The Reply @Palaniyappan

In My Excel Sheet The Date is ex:- 08-06-2017(“MM/dd/yyyy”).I want to match only date and month(“MM/dd”) with the current date & month(“MM/dd”) Not The Year.

Thanks

Use a SubString like
row(” yourcolumnname”).ToString.SubString(0,5)
And mention the same date format in parse exact method as well

Cheers @omprasad

hi i am facing similar issues but when i am putting the condition in the if statement it is moving in he else part instead of then part.
my problem statement is to match the excel date with current date.

1 Like

You want to match only Date?