Check out example codes for "sql time format". It will help you in understanding the concepts better.

Code Example 1

SELECT DATE_FORMAT("2017-06-15", "%Y");

Code Example 2

Pressupondo uma tabela utilizador u.

year(u.DataInicio) --> Retorna o ano
month() --> Retorna o mês
day() --> dia

Exemplo:
u.Ativo = 1 AND year(u.DataInicio)<= 2018

Code Example 3

DATE - format YYYY-MM-DD
DATETIME - format: YYYY-MM-DD HH:MI:SS
TIMESTAMP - format: YYYY-MM-DD HH:MI:SS
YEAR - format YYYY or YY

Learn ReactJs, React Native from akashmittal.com