About strtotime

164 views Asked by At

I stored data with created datetime(Y-m-d H:i:s) using strtotime function in my database. But now I need to find those stored data by using only year value. How can i do that in php or sql query?

1

There are 1 answers

0
TobyLL On

This SQL will return data from 2014 only, assuming you have stored the data in a field with the datetime data type:

SELECT *
FROM mytable
WHERE datefield >= '20140101'
AND datefield < '20150101'