Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Apr 2010
    Posts
    207
    Thanks
    30
    Thanked 0 Times in 0 Posts

    SQL Join using dates - error

    ok, I am trying to Generate a query that lists all company names of customers who placed one or more orders during November 1996. The 2 tables are Orders and Customers.

    I am getting the following error...not sure what I am doing wrong. Can anyone help me out?

    Msg 241, Level 16, State 1, Line 2
    Conversion failed when converting date and/or time from character string.

    My code:
    Code:
    SELECT Customers.CompanyName AS OrdersPerCustomer
    FROM Customers JOIN Orders
    ON Customers.CustomerID = Orders.CustomerID
    WHERE OrderDate = '1996-11'
    I am not sure how exactly to pull the dates, apparently.

    ---------------------------------------------------------------------------------------------------------
    After I posted this...I decided to try something and that worked...sorry for the inconvenience

    NEW CODE:
    Code:
    Use Northwind;
    SELECT Customers.CompanyName AS OrdersPerCustomer
    FROM Customers JOIN Orders
    ON Customers.CustomerID = Orders.CustomerID
    WHERE OrderDate BETWEEN '1996-11-01' AND '1996-11-30'
    Last edited by CarlMartin10; 08-18-2010 at 01:41 AM.
    Website: www.billboardfamily.com
    Twitter: www.twitter.com/billboardfamily
    Facebook Fan Page: www.facebook.com/BillboardFamily
    Facebook (Carl): www.facebook.com/CarlMartin.BillboardFamily (admin note: sig should be <=4 lines)


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •