Check birthdays of the current month in SQL [closed]

2

I need to run a birthday visit for the current month. But I would like it to be automatic, and not have to enter the month. Below is the example I made by typing the month.

NOTE: My field is dt_nasc (TIMESTAMP) .

SELECT * from top_007 where extract(month from dt_nasc)='9'; //referente ao mes 9

Could anyone help me?

    
asked by anonymous 27.09.2017 / 19:58

2 answers

4

Use the now() function combined with month() to get the current month.

SELECT * from top_007 where month(dt_nasc) = month(now())
    
27.09.2017 / 20:13
1

If SQL SERVER is the command would look like this:

SELECT * from top_007 where MONTH(dt_nasc) = MONTH(GETDATE())
    
27.09.2017 / 22:59