I need to compare a date without the time, only ("dd/MM/yyyy")
with the database with Linq
, but I am not able to transform from DateTime("dd/MM/yyyy HH:mm:s")
to Date("dd/MM/yyyy")
format?
I need to compare a date without the time, only ("dd/MM/yyyy")
with the database with Linq
, but I am not able to transform from DateTime("dd/MM/yyyy HH:mm:s")
to Date("dd/MM/yyyy")
format?
To do this, simply do the following: just get the date of the DateTime object.
Example:
DateTime apenasData = DateTime.Now.Date;
It will set the time to 0.
So, to use linq, you can use:
resultado = lista.Where(x => x.DataComparada.Date <= dataComparar.Date);