Q:

Compare int with DateTime

I need to compare a int value with a datetime in a SQLExpress table. 
Here´s the code I tried with, but didn´t work: 
        String query = "select id, erstelldatum, enddatum, text, erledigt, prioritaet from Aufgaben where loginid = " + loginid + " AND erstelldatum LIKE "+ jahr +";";

So jahr is the year of the datetime and I want to get every date out of this year.
Just know how to compare it with a string but not with a datetime. Any ideas?

A:

Why not use Year function?
String query = "select id, erstelldatum, enddatum, text, erledigt, prioritaet from Aufgaben where loginid = " + loginid + " AND year(erstelldatum) = "+ jahr +";";

