Calendar control as Date Query problem.

Discussion in 'ASP .Net Web Controls' started by Nithin, Jan 22, 2004.

  1. Nithin

    Nithin Guest

    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??
    Nithin, Jan 22, 2004
    #1
    1. Advertising

  2. Nithin

    CMA Guest

    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" <> wrote in message
    news:...
    > 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??
    CMA, Jan 23, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shevek
    Replies:
    3
    Views:
    6,008
    Shevek
    Jun 23, 2004
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,196
    Michael Borgwardt
    May 30, 2004
  3. Nathan Sokalski
    Replies:
    1
    Views:
    727
    Mark Rae
    Jan 11, 2007
  4. Shevek
    Replies:
    0
    Views:
    373
    Shevek
    Jun 23, 2004
  5. Si

    Date/Calendar query

    Si, Aug 25, 2005, in forum: ASP General
    Replies:
    2
    Views:
    131
    Bob Barrows [MVP]
    Aug 25, 2005
Loading...

Share This Page