Hi,

I am using timestamp datatype for storing date..and value of column is like
2013-12-31 T 23:59:59.000Z

For query

SELECT * FROM a WHERE created_on BETWEEN '20131201' AND '20131231'
SELECT * FROM a WHERE created_on >= '20131201' AND created_on <= '20131231'

Which will give right result??

Recommended Answers

All 2 Replies

both will give result but user hyphen
1) '2013-12-01'
2) as yor column is timestamp, it will only give records
which are 2013-12-31 00:00:00
any value more then that will not include for same day

Following query should work

SELECT * FROM a WHERE created_on >= '2013-12-01' AND created_on < '2014-01-01'

Hi, How about:
SELECT * FROM a WHERE YEAR(created_on) = 2013 AND MONTH(created_on) = 12

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.