How filter previous year

In datatable ,I need to filter the previous year with annual

Stmt date type
12/31/2020 annual
12/31/2019 annual
12/31/2019. Review

So the output should be
12/31/2029 annual in datatable

@sruthesanju

I didn’t get your query. Can you please elaborate it.

If my input is 12/31/2020
In datatable I have to see the previous statement of the year 2020
Which has type annual in it.so my output should be 12/31/2019 annual

Hi

Hope this expression will help you resolve this

—use excel application scope and get the datatable with read range activity and name as dt

—then use a assign activity like this

dt = dt.AsEnumerable().Where(Function(a) a.Field(of String)(“yourcolumnname”).ToString.Contains(Datetime.AddYears(-1).ToString(“yyyy”)+” “+”annual”)).CopyTodatatable()

Cheers @sruthesanju


I ma getting the above error

Hi, @sruthesanju

Can you please try this,

DateAdd(DateInterval.Year, -1, Cdate(year)).ToString(“MM/dd/yyyy”)

Aah
It was a typo

Mention like this

dt = dt.AsEnumerable().Where(Function(a) a.Field(of String)(“yourcolumnname”).ToString.Contains(Datetime.Now.AddYears(-1).ToString(“yyyy”)+” “+”annual”)).CopyTodatatable()

I missed Datetime.Now.AddYears

Hope this would help you

Cheers @sruthesanju