Filter Date in Date Table?

I have Data table name resultDt The datas are shown below

My requirement is to get the last 3 months count of the name.

For example NewDate = today.Addmonths(-3) it will give 03-04-17.Now the NewDate is Compare to DataTable resultDt.After the NewDate I have 3 records So it Should return Count of Rows as “3”.

Can some one help me to achieve this.

Thanks in advance
(Jothyprasanth M)

How about resultDt.Select("Date >today.Addmonths(-3)") ?

NewDate=DateTime.Today.AddMonths(-3)

resultDt.Select("Date =’ “+NewDate+” ’ " )

i tried this way but i shows Error like

“Implicit Conversion from ‘Date’ to ‘String’”

Try

string NewDate=DateTime.Today.AddMonths(-3).ToString(“MM-dd-yy”)

resultDt.Select("Date >=’ “+NewDate+” ’ " )

It gives error like this
Assign : Syntax error: Missing operand after ‘Date’ operator

Date is a DateTable Column

The resultDt DataTable values are extracted from Extract Structured Data Activity

I would try few things

Keep date in Brackets [Date] — Incase of space in Column name

Try # instead of single quotes (“Date = #”+NewDate+"#" )

1 Like

We should assign this as DataRow Right?

DateRow Array → Select Array and Datarow as Type

Oops …

Error : Cannot Find the Column [Date]

@vvaidya, @Rammohan91 @siddharth

I want to filter dates less than ‘01-12-2017’ from attached excel file. Could you please help me in this.
Scrapped data.xlsx (13.3 KB)

Regards,
Lakshman

Hi Lakshman,

Use DateTime.Compare(date1, date2) Method for this. If it returns a -ve integer, date1 is earlier than date2. If it’s a positive integer, date1 comes after date2. If it’s a 0, the dates are equal.

Try to do this yourself first. If you’re not able to do so yourself, you can come back later and attach your workflow here.

Have a good day!

@jothyprasanth.m

Try like this

intNameCount= (From p In resultDt.Select
                          Where DateTime.ParseExact(p("Date").ToString,"dd/MM/yy",System.Globalization.CultureInfo.InvarientCulture)>=DateTime.Now.AddMonths(-3)
Select p).Count

Regards,
Mahesh

@jothyprasanth.m

While Using Read Range check Add Headers Property.

and also check is there any space in Column Name .

Regards,
Mahesh

1 Like