Mayank Jani

Mayank Jani

  • NA
  • 477
  • 76.6k

To find records between two dates.

Sep 16 2017 9:56 AM
Dear All,
 
Greetings of the day.
 
I am working on an application named Hotel Management and it is about to keep all the records from guest check-in to check-out. I am using VS2008 and MS Access as database.
 
while running a report of guest checkin, i found some problem. the report runs but does not show the correct result. there are two datetimepickers, one command button and one data grid view.
 
>the guests checked in between  01/07/2017 and 18/07/2017
>when i select dates between 01/07/2017 and 09/07/2017, it shows all the records beyond 09/07/2017.
>when i select dates between 01/07/2017 and 05/07/2017, it shows messagebox 'No Record Found'.
 
my query is...
OleDbDataAdapter DateRecord = new OleDbDataAdapter("Select * From Guests Where CheckIn Between #" + dtpFrom.Value.Date.ToShortDateString() + "# AND #" + dtpTo.Value.Date.ToShortDateString() + "#", myconn);

if i put dtpFrom.Value.Date.ToShortDateString() instead of  dtpTo.Value.Date.ToShortDateString(), it shows no record for any criteria.
 
Kindly help to let me know where i am mistaking.
Please see the screen shots for more clarification, if required.
 
Thank You,
 
Mayank Jani

Attachment: Report.zip

Answers (2)