Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Calendar control as Date Query problem.

Reply
Thread Tools

Calendar control as Date Query problem.

 
 
Nithin
Guest
Posts: n/a
 
      01-22-2004
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??
 
Reply With Quote
 
 
 
 
CMA
Guest
Posts: n/a
 
      01-23-2004
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



"Nithin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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??



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting a date with the Calendar control clears the FileUpload control Nathan Sokalski ASP .Net 1 01-11-2007 06:47 AM
Selecting a date with the Calendar control clears the FileUpload control Nathan Sokalski ASP .Net Web Controls 0 01-11-2007 05:13 AM
Calendar Control - Programatically set the calendar to a date range Shevek ASP .Net 3 06-23-2004 01:41 PM
Calendar Control - Programatically set the calendar to a date range Shevek ASP .Net Web Controls 0 06-23-2004 12:06 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM



Advertisments