Need query to get count of records only for the year 2022

I have extracted a data table from a website and am trying to get count of movies released in the year 2013.

You will find the table I am extracting in this link: https://www.databasestar.com/sample-database-movies/

I have tried several queries to get the count but not able to.

(From row In dt_Filtered_Datatable.AsEnumerable Where CDate(row(“When”).ToString) >= CDate(“01/01/2022”) And CDate(row(“When”).ToString) >= CDate(“12/31/2022”) Select row).CopyToDataTable.rowCount

(From row In ExtractDataTable.AsEnumerable Where CDate(row(“ReleaseDate”).ToString) >= CDate(“2022/01/01”) And CDate(row(“ReleaseDate”).ToString)<CDate(“2023/01/01”) And CDate(year(row(“ReleaseDate”).ToString)) =CDate(“2022”) Select row)).rowCount

(From p In ExtractDataTable.Select() Where(p(“ReleaseDate”).ToString = “2022”)).Count.toString

Can I get some solution for this please?

HI @himaja.kr

Welcome to community!

Checkout this expression

ExtractDataTable.Where(Function(f) DateTime.ParseExact(f(2).ToString,"yyyy-MM-dd",System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).Year=2022).CopyToDataTable.Rows.Count

if the count is not there means this expression will throw you error like source contains no datarow

so wht you can do is

Put this expression in the if condition like

ExtractDataTable.Where(Function(f) DateTime.ParseExact(f(2).ToString,"yyyy-MM-dd",System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).Year=2022).Any

It returns true if you have count
then in true you can use the 1st expression i sent and get the count

Regards
Sudharsan

Regards
Sudharsan

DT.asenumerable.count(Function(r) CDate(r(“Datecolumn”).Tostring).Year=2022)