none
Orders in a single day only RRS feed

  • Question

  • Hello,

     

    My SQL knowledge is pretty limited so I hope someone can help me resolve what appears to be a simple problem. Basically, I would like to write a query that returns all orders made in a single day only. Something like:

     

    SELECT * FROM Orders

    WHERE (OrderDate is unique). 

     

    The problem is how to interprete OrderDate is unique.

     

    Thank you for any help.

     

    Patrice

     

    Sunday, December 2, 2007 8:55 PM

Answers

  • replace the "startdate" and the "enddate" with parameters.

     

     

    If you are using a stored procedure you can use two input parameters

    named i.e.

     

    @starttime

    and

    @endtime

     

    and use these in your query

     

    i.e.

     

    select *

    from orders

    where orderdate between @starttime and @endtime

    Monday, December 3, 2007 10:15 AM

All replies

  • Perhaps u could use the between operator in your sql.

     

     

    select *

    from Order

    where orderdate between '01.01.2007 00:00' and '01.01.2007 23:59:99'

     

     

    Harry

    Monday, December 3, 2007 9:40 AM
  • Thank you for replying Harry. How can I transorm this solution into a generic one? I mean a general one as opposed to using the date '01.01.2007'.

     

    Thanks again.

     

    Patrice

    Monday, December 3, 2007 10:10 AM
  • replace the "startdate" and the "enddate" with parameters.

     

     

    If you are using a stored procedure you can use two input parameters

    named i.e.

     

    @starttime

    and

    @endtime

     

    and use these in your query

     

    i.e.

     

    select *

    from orders

    where orderdate between @starttime and @endtime

    Monday, December 3, 2007 10:15 AM
  • Thank you Harry.

     

    Patrice

    Monday, December 3, 2007 6:16 PM