2017-03-16 27 views
-1

The table is hereSQL查詢來發現當月的日期

問題是由流派當月,產生的最新的電影名單。如何從日期查找當前月份?

+0

其中RDBMS是你使用了(你在這裏標記了兩個不同的),你是否嘗試用Google搜索答案? – TZHX

+0

顯示文本非img ... – scaisEdge

+0

可能重複[在SQL Server中截斷日期的最佳方法是什麼?](http://stackoverflow.com/questions/2639051/what-is-the-best-way- to-truncate-date-in-sql-server) –

回答

0

您正在尋找DATEPART()

Select 
    * 
From YourTable 
Where 
    datepart(month,ReleaseDate) = datepart(month,getdate()) 
and datepart(year,ReleaseDate) = datepart(year,getdate()) 
Order by Genre, ReleaseDate desc 
+0

謝謝!有效!! :) – V0711

0

你可以試試這個:

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

其中:

格式的日期,你只有一個月