Compare excel date to today's date

I need to compare dates in an excel file to today’s date. If the dates equal, then I will execute an action. I only need to compare the date and not the time.

Here is the write line for the excel values

image

Here is the value in the spreadsheet. The first line below is the first for each value read

3/25/2019
8/15/2018
8/23/2018
8/29/2018
9/3/2018
9/3/2018
9/3/2018
9/4/2018
9/8/2018
9/8/2018

@tsweat,

  1. use Read Range activity to read data from Excel file and will give you output as dataTable and say it DT.

  2. Then itreate it using For Each Row activity

If Row(“DateColumn”).Tostring = Now.Tostring(“mm/dd/yyyy”)
Then execute your action
Else skip it

2 Likes

under the if statement can we use
If Row(“DateColumn”).Tostring = now.ToShortDateString

instead of If Row(“DateColumn”).Tostring = Now.Tostring(“mm/dd/yyyy”) ???

1 Like

Thank you so much for your answer. My variable in the DT is named “beginrenewdate”. I inserted it using your instructions and am getting error of below

image

here is my variable in the expression

image

you have to mention the name of the column not the data table.

share you excel sheet let me help you out here.

1 Like

renew date.xlsx (8.3 KB)

try this
Main.xaml (8.2 KB)

1 Like

email from spreadsheet.xaml (16.2 KB)

Thank you for trying. It produced an error each time (I created a write line of “error” if it failed). I am attaching the xaml if you want to look. My automation looks at a spreadsheet (larger than the one I sent you) and assigns a variable to the field that I sent you (date). I compared this date to now.toshortdatestring and it failed. It did not matter whether i did it this way or by referencing the row(“date”).tostring method that you sent me and I did change"date" to my column name. I will send the output screen shot next. Thank you again.

image

Hi @lakshman

i m facing a little diff scenario.
in that there is an excel sheet containing date column with time
eg.–11/13/2019 12:26:49 AM
So scenario is when i run the bot first time lets say 11/13/2019 12:26:49 AM on this date and time.
now if i hv to run the bot again on same date but after 12:26:49 AM like 05:30:33 PM
then Bot should not include the data associated with 12:26:49 AM this time …it should process the data from the last time when i ran the bot…

Any help will be appriciated…
Thank in advance…

hi @lakshman
is there any suggestion for above thread??

@psujatha

Could you please show me screenshot of some sample input and output data. So that i can check and let you know.

sure lakshman
pls have a look at screenshot.
DateColumn1

Hope it will help you to figure it out…
Thanks for your concern

@psujatha

Now tell me what you want to do with this data ? From this which record you want to consider ?

as you can see in above image.

on daily basis i am exporting this file from web, and i am getting some comments in another column of this excel and i have to print those comments in a word file one by one.
let’s say 2019-11-11 08:59:11 am i got one comment , now if i run the bot again at 04:20:22 pm
suppose i get 5 more entries after 08:59:11 am till 04:20:22 pm .
now my requirement is ,when i run the bot again i want to get only those comments that came after 08:59:11 am.

Hope you got some idea…
if not pls let me know…
Thankyou!

1 Like

@psujatha

In that case, you have to assign previous run time value in one variable and better to keep it in config value.

Whenever you are running the BOT then first you have to read that time and then proceed further.

1 Like

yes doing the same but after reading ,what kind of activities i need to use?
Can you please suggest?

@psujatha

Read that value from config file and assign it to String variable and check whether that date is less than or not.

If it less then skip it else continue with that record.

i need to compare both date and time also.
can u help me with date time comparison code.
that will be very helpful…

Thank you for your time