Crowley91t
Crowley91t

Reputation: 107

Query to get values between two dates

I'm looking to create this query but nothing.

I need to get some values between two dates.

MY table contain id, value, startdata, enddata.

id=1; value=x; startdata=2017-03-12; enddata=2017-03-19

startdata and enddata are DATA Type.

My query :

SELECT * FROM listino where  startdata>='2017-03-13' AND enddata<='2017-03-13' 

but no work. how to get value from this table?

Upvotes: 0

Views: 305

Answers (3)

Justin Burgard
Justin Burgard

Reputation: 470

Use this, beacuse you're comparing strings not dates.

WHERE startdata>= DATE('2017-03-13) AND enddata<= DATE('2017-03-13)

Upvotes: 1

sameera lakshitha
sameera lakshitha

Reputation: 1971

Try this codes. It helpful this problem.

Select * from listino where dates between '2017/03/12' and '2017/03/19'

Or

Select * from listino where dates between startdate and enddate

Upvotes: 0

SELECT * FROM listino where startdata = '2017-03-13'

or

SELECT * FROM listino where startdata between ('2017-03-13' AND '2017-03-13')

or

SELECT * FROM listino where startdata between '2017-03-13' AND '2017-03-13'

Upvotes: 1

Related Questions