0

How can I select rows from my database with date more than 2017-12-05 but less than 2017-12-12 ?

const start = moment().format('YYYY-MM-05');
const end = moment().format('YYYY-MM-12');

This is my mysql request:

'SELECT id, content, date, own FROM quests 
WHERE  '+start+'>="date" AND "date">='+end+'
ORDER BY date DESC'

In my mysql I have date format YYYY-MM-DD. This request select rows with date 0000-00-00.

1 Answer 1

3

Use between operator

'SELECT id, content, date, own FROM quests 
WHERE  `date` BETWEEN \''+start+'\' AND \''+end+'\'
ORDER BY date DESC'
Sign up to request clarification or add additional context in comments.

2 Comments

Still the same problem select only date with 0000-00-00
I've updated my answer a bit. Try now. The date should be in quotes.

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.