0

i have this table:

Players:
ID (int)
Birthday (datetime)

I need choose 3 first players, which have birthday in the actual month... I have this but the result is nothing.. Have you any idea?

SELECT * 
FROM Players
WHERE Birthday < DATEADD(month, -2, GETDATE())
Kate
  • 372
  • 2
  • 11
  • 24

2 Answers2

3

You need to use DATEPART function in SQL server

SELECT * 
FROM Players
WHERE DATEPART(MM,Birthday) = DATEPART(MM,GETDATE())
Debajit Mukhopadhyay
  • 4,072
  • 1
  • 17
  • 22
1

Using SQL Server syntax:

select  top 3 *
from    YourTable
where   datepart(month, Birthday) = datepart(month, getdate())
Andomar
  • 232,371
  • 49
  • 380
  • 404