Linq to compare dates

Hi Everyone,

I want to compare the date and get result as per the condition,

Input Data:

image

Condition 1) StartDate is less than or equal to current date and enddate is Greater than current date.
Condition 2) End date is less than today/current date.

Thanks

1 Like

Hi @ShekharRPA
try out this

(From r In DT
Where DateTime.Parse(r("StartDate").toString).Date.tostring("dd-MM-yyyy")<=Today.Date.tostring("dd-MM-yyyy")  And
DateTime.Parse(r("End Date").toString).Date.tostring("dd-MM-yyyy")  >Today.Date.tostring("dd-MM-yyyy")
Select r).CopyToDataTable

condition 2

(From r In DT
Where DateTime.Parse(r("End Date").toString).Date.tostring("dd-MM-yyyy")<Today.Date.tostring("dd-MM-yyyy")  
Select r).CopyToDataTable

hope this helps

2 Likes

and if we have to get only count of rows not the dt row. then?

1 Like

so instead of copytodatatable just go with . count @ShekharRPA

store that value if needed to an integer type

1 Like

Thanks @nikhil.girish
can DM some resource for LinQ :slight_smile:

1 Like

[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

1 Like

Thanks @ppr :smiley:

Hi,

Can check this, getting an error of string not recorgnised as valida date format

(From r In DT
Where DateTime.ParseExact(r(“EndDate”).toString, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture) < Today
Select r).count

(From r In DT
Where DateTime.ParseExact(r(“EndDate”).toString, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture) < Today
Select r).copytodatatable

Hi @ShekharRPA
please use the above syntax what i had given you earlier

:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

1 Like

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