-1

The table is here

The question is to Produce a list of the latest movies by genres for the current month. How to find the current month from the Date???

S3S
  • 24,809
  • 5
  • 26
  • 45
V0711
  • 13
  • 3

2 Answers2

0

You are looking for DATEPART()

Select
    *
From YourTable
Where 
    datepart(month,ReleaseDate) = datepart(month,getdate())
and datepart(year,ReleaseDate) = datepart(year,getdate())
Order by Genre, ReleaseDate desc
S3S
  • 24,809
  • 5
  • 26
  • 45
0

You can try this:

SELECT  SUBSTRING(TO_CHAR(now(),'YYYYMMDD'),5,2)

In which:

Format to date and you get only the month

AT82
  • 71,416
  • 24
  • 140
  • 167