Calendar control as Date Query problem.

N

Nithin

I have a Start_date fieild as datatime on my SQL server (eg)
01-22-2003 2:11:41 PM.

I use 2 Calendar control to generate a datagrid of records that were
created between the 2 dates, namely Beginning Date and Ending Date.

The following query works but when EndDate is today's date it displays
records till yesterday and I guess is the problem when I try to use
only 1 calendar control to display records for particular date only.

strSQL = "SELECT *" & _
" FROM Tracker2 " & _
" WHERE Start_date >= '" & BeginDate.SelectedDate & "' AND Start_date
<= '" & EndDate.SelectedDate & "' AND Ticket_type='" &
ddlTicketType.SelectedValue() & "' ORDER By Start_date"

If StartDate=1/1/2004 and EndDate = 1/22/2004 it displays records from
1/1/2004 till 1/21/2004 (not 1/22/2004)

I would like to use only 1 Calendar control and changed the WHERE part
of the query to " WHERE Start_date = '" & BeginDate.SelectedDate & "'

Is it bcos of the datetime format..if so how do I rectify it??
 
C

CMA

as in the example u given, u need to view records of 22nd also.
the problem is when u select a date, it get as 1/22/2004 12.00.00 AM that
means early morning of 22nd.
so, u have to update the end date as....

strSQL = "SELECT *" & _
" FROM Tracker2 " & _
" WHERE Start_date >= '" & BeginDate.SelectedDate & "' AND Start_date
<= '" & EndDate.SelectedDate & " 11:59:59 PM' AND Ticket_type='" &
ddlTicketType.SelectedValue() & "' ORDER By Start_date"

i just added " 11:59:59 PM" after the end date u selected. this will get u
the entries for the 22ns also...
hope this helps.
regards,
CMA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top