Answer the question
In order to leave comments, you need to log in
MySQL - how to make a selection by year?
Hello!
In the database, each record has its own timestamp attached, at the PHP level I have a value like "2013".
How to write a query to select records corresponding to a given year?
View request:
SELECT FROM_UNIXTIME(`time_stamp`, '%Y') AS year FROM `announcement` WHERE YEAR(`time_stamp`) = '2013'
Answer the question
In order to leave comments, you need to log in
Better WHERE `time_stamp` BETWEEN '2013-01-01 00:00:00' AND '2013-12-31 23:59:59' so that the index is used (of course, if there is one)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question