Select all people who have the anniversary date greater than 2000

1

I'm trying to select all the people who have the anniversary date beyond 2000 This date has to be accurately taking into account the day and the month, not simply decreasing the year!

    
asked by anonymous 05.09.2018 / 12:56

2 answers

4

How to do

SELECT *
FROM usuarios
WHERE YEAR(nascimento) > 2000

How to filter parts of a date

Use the YEAR, MONTH, DAY functions that take YEAR, MONTH, DAY from the date field:

SELECT * FROM usuarios
WHERE YEAR(nascimento) = '2000' AND MONTH(nascimento) = '07' AND DAY(nascimento) = '07'

If you have more than 1 value:

SELECT * FROM usuarios
WHERE YEAR(nascimento) = '2018' AND MONTH(nascimento) IN ('07','09','11')

In a sequential range:

SELECT * FROM usuarios
WHERE YEAR(nascimento) = '2018' AND MONTH(nascimento) BETWEEN '05' AND '12'

Running on db-fiddle

As our friend posted in the comments.

Useful links

MySQL - Date and Time Functions

    
05.09.2018 / 13:02
0

You can do this

SELECT * FROM usuarios WHERE nascimento >= 2000
    
06.09.2018 / 01:03