Mysql looks up the data, how to find out only the year of the data, as shown in the following figure

< H2 > question < / H2 >

mysql looks for data, but how to find out only the year of the data?
for example, there are data of 2016 create_at, 2017 and 2018 in create_at.
I just want to get 2016, br, 2017, 2018
clipboard.png

clipboard.png

. < H2 > Code < / H2 >
SELECT
    created_at
FROM
    `blogs` 
where  DATE_FORMAT(created_at,"%Y");
Oct.14,2021

SELECT
    YEAR(created_at)
FROM
    `blogs`;

year


SELECT FROM_UNIXTIME (created_at,'% Y') FROM blogs


  

select distinct (year (created_at)) from blogs;

Menu