0

I would like to select all records before 2014-03-22 date:

 where date < 2014-03-22 // what I need

but below code doesn't see 2013 year's records :

SELECT * FROM `tractions` WHERE YEAR(date) <= 2014  AND MONTH(date) <= 3 and  DAY(date) <= 22 and succ = 1
2
  • following link may help you stackoverflow.com/questions/696438/… Commented Aug 29, 2016 at 15:47
  • That second query is not only over-complicating things, it's completely wrong. Commented Aug 29, 2016 at 16:02

1 Answer 1

2

Is there anything wrong with:

SELECT * FROM tractions
WHERE date < '2014-03-22'    -- place the date, correctly formatted, in quotes

Since this comparison doesn't use any functions, it will also allow you to use any indices setup on the date column.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.