3 Replies - 700 Views - Last Post: 18 July 2011 - 12:37 AM

#1 Public Designs  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 145
  • Joined: 08-November 08

select orders on a specific date with WHERE

Posted 17 July 2011 - 11:58 AM

SELECT        SalesOrderID, SalesOrderDetailID, ProductID, LineTotal, ModifiedDate
FROM            Sales.SalesOrderDetail
WHERE        (ModifiedDate = 'July 1, 2005') OR
                         (ModifiedDate = '07/01/2005')
ORDER BY SalesOrderID, SalesOrderDetailID


This is what I have and is not bring back any values. I am again using the adventure works database.
Am I setting up the date selection wrong because I know there should be some brought back but the statement is returning nothing.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: select orders on a specific date with WHERE

#2 Cocker081288  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 108
  • Joined: 11-April 09

Re: select orders on a specific date with WHERE

Posted 17 July 2011 - 01:03 PM

Could it be your date format?

It may not be working because its expecting the where clause to be '01 July 2005' as it could be currently reading it as '06 01 2005' instead.

View PostCocker081288, on 17 July 2011 - 01:02 PM, said:

Could it be your date format?

It may not be working because its expecting the where clause to be '01 July 2005' as it could be currently reading it as '06 01 2005' instead.

sorry I meant 07 01 2005
Was This Post Helpful? 0
  • +
  • -

#3 Public Designs  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 145
  • Joined: 08-November 08

Re: select orders on a specific date with WHERE

Posted 17 July 2011 - 01:57 PM

No. I have tried that and it brings back no results as well
Was This Post Helpful? 0
  • +
  • -

#4 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: select orders on a specific date with WHERE

Posted 18 July 2011 - 12:37 AM

When working with dates in SQL, I use the following format: 'YYYYMMDD'
select * from Table where DateField = 'YYYYMMDD'



Also, you have functions to convert the date to a format that you like. Take a look at convert. Here you find the list of all functions to manipulate dates.
Finally, if the query doesn't return any value, delete all the where conditions and add one by one and see where the result set dissapears. In your case, try using < or > or other date to see if you get any values.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1