Link to home
Start Free TrialLog in
Avatar of JackOfPH
JackOfPHFlag for Philippines

asked on

Filter between two dates?

How do you filter data using LINQ between two dates...

I tried this code but to no avail:

Dim dtDesde as dateTime = datepickerDesde.Value
Dim dtHasta as dateTime = DatepickerHasta.value

Dim employeeList = From Employee In TimeOneDataContext.Employees Where Employee.RecordDate >= dtDesde.ToShortDatestring And Employee.RecordDate <= dtHasta.ToShortDateString Select Employee


I checked the database and confirmed that there is a Recorddate that is between the above date?

Any idead how to filter dates in LINQ?
Avatar of HainKurt
HainKurt
Flag of Canada image

do you get any records when you try these
Dim employeeList = From Employee In TimeOneDataContext.Employees Select Employee

Dim employeeList = From Employee In TimeOneDataContext.Employees Where Employee.RecordDate <= dtHasta.ToShortDateString Select Employee

Dim employeeList = From Employee In TimeOneDataContext.Employees Where Employee.RecordDate >= dtDesde.ToShortDatestring Select Employee

Open in new window

Avatar of JackOfPH

ASKER

Yes, I do have...
you have? how many on each of those?
maybe you should reverse these

Dim dtDesde as dateTime = datepickerDesde.Value
Dim dtHasta as dateTime = DatepickerHasta.value

are you sure  dtHasta >= dtDesde ???
SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
spanish
how can you remove the time in the Employee.RecordDate? In the above query?
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial