I am trying tomake a select join between two specific dates in the database
This I feelis on the right path but is incorrect
How can I get this to work
SELECT --RTRIM(C.CustomerFirstName) + ' ' + LTRIM(C.CustomerLastName) as CustomerFullName,
ROW_NUMBER() OVER(ORDER BY CP.ActionDate) AS RowNumber,
C.CustomerFirstName,
C.CustomerLastName,
C.CustomerCompany,
C.CustomerPosition,
C.CustomerCountry,
C.CustomerProvince,
C.CustomerContact,
CP.ActionDate,
CP.ProductCode,
CP.CustomerEmail
FROM tblCustomers C
JOIN tblCustomerProducts CP
ON C.CustomerEmail = CP.CustomerEmail
ORDER BY ActionDate DESC
WHERE CP.ActionDate BETWEEN '1/17/2013' AND '19/12/2012'
Instead of
Try this:
Note that: This is because the
BETWEENpredicate in SQL Server is Asymmetric, this means thatvalue1 BETWEEN value2 AND value3is the same asValue1 >= Value2 AND Value1 <= Value3, so the valuevalue2that before theANDmust be less than or equal to thevalue3.