0

I have following data which clearly showing data available between date used in query enter image description here

My query

SELECT * FROM dashboard WHERE added BETWEEN "2018-05-08 10:32:32" AND "2018-05-08 10:28:30"

but This query returning empty row set. What going wrong. I have exported this table from production server & imported in development server. addedfield is DATETIME. Please help

1

2 Answers 2

3

The first boundary must be lower than the second.

Try reversing the comparison values. E.g

SELECT * FROM dashboard 
WHERE added BETWEEN "2018-05-08 10:28:30" 
      AND "2018-05-08 10:32:32"

The reason behind this is due to the fact that the first value is compared using >= then the second value compared using <= thus the second value must be greater than the first or nothing is returned.

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

Comments

1

the clause: BETWEEN "2018-05-08 10:32:32" AND "2018-05-08 10:28:30" is correctly returning an empty set since from is after until. Did you mean:

BETWEEN   "2018-05-08 10:28:30" AND "2018-05-08 10:32:32" 

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.