How to check the date condition

Hi Team,

I need to get the row from the datatable on the basis of date comparison.

Filter the records where Date is newer than ‘1st of February 2018’ (discard older records)

how to check this condition in if block.

Please help its urgent

Hey @Karan28
You can use greater than condition in a “IF BLOCK”.
Pass the date values in a variable having datetime datatype
For Eg:
filter_date(datetime datatype) > CDate(01 February 2018)
write the above query in if statement
Try this and let me know if u have any queries.

Thanks!

Hi @Karan28

Cdate(row(“Date1”).ToString(“ddMMMyyyy”)<Now.ToString.AddDays(-30).ToString("
ddMMMyyyy")

Check this

Thanks
Ashwin S

1 Like

yyyy-MM-dd
this is the date format in the webpage

I dont understand this , please explain more

i think this will be ok for you , hope if you are using SQL Database and you should convert the date before getting,

Hi @Karan28

Change the format like that

Thanks
Ashwin S

@Karan28 If we are comparing Dates, i think both the dates should be in Date Type format and not in String

@Karan28
have a look on this.
image

Instead of Date just pass the variable .
‘CDate’ will convert the date from whatever format it is and will check and give the desired answer.

Thanks!

Hi,

I am scraping the data from web page and it is in datatable variabe now.

in column date I have values like 2019-09-24

Like this and I have to apply the condition if date is newer than 2018-02-01 then only take that row

Hi @Karan28

Cdate(row(“Date1”).ToString(“yyyy-MM-dd”)<Cdate(“2018-02-01”).ToString

Check this

Thanks
Ashwin S

hey to append the filtered row in excel?
using add data row ?

add data row is not working

@Karan28
May I know what error u are getting?

Thanks!

yes ,

Add Data Row: This row already belongs to another table

Hi @Karan28

before add data row ensure you do the clear datatable activity

Thanks
Ashwin S

1 Like

which datatable to mention in clear data table?

one we got from the data scarping or the one where we are pasting the filtered rows?

Hi @Karan28

Where you are filtering the rows

Thanks
Ashwin S

this is not working

is there any method than add data row?

Hi @Karan28

try this

Thanks
Ashwin S