I have a Datatable
with a column "Datum" that is typeof(DateTime)
.
I want to select all rows for the actual month:
DataRow[] foundRows = dt.Select("Datum >='" + new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1) + "' AND Datum <='" + new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) + "'");
I'm getting the error
Cannot perform '<=' operation on System.String and System.DateTime
If I split the select statement the first one is running well, the second get the same error:
Select 1 is working:
DataRow[] foundRows1 = dsLinie.Tables[0].Select("Datum >='" + new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1) + "'");
Select 2 get the error:
DataRow[] foundRows2 = dsLinie.Tables[0].Select("Datum <='" + new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) + "'");
Why do I get the error, both select statements query the same DateTime
column "Datum"?