Convert DateTime to Date [duplicate]

-2

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?

    
asked by anonymous 24.10.2018 / 21:09

1 answer

0

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);
    
24.10.2018 / 21:18