Last post Dec 19, 2013 05:58 AM by gahhon
Dec 19, 2013 05:20 AM|gahhon|LINK
SELECT Date FROM MemberStatusModification WHERE Date=@date ORDER BY Date, Manager
In this statement, i want to retrieve the Date where my Date is meet selected month and year only, so ignored the day.
How can i do in order to reach my target?
Dec 19, 2013 05:32 AM|AidyF|LINK
select Date from MemberStatusModificatoin where Month(Date) = Month (@date) and Year(Date) = year(@Date)
Dec 19, 2013 05:41 AM|PatriceSc|LINK
Hi, or my favorite approach :
SELECT Date FROM MemberStatusModification WHERE Date>=@Date AND Date<DATEADD(month,1,@Date) ORDER BY Date,Manager
@Date being the first day of the month you want (especially if you have an index on the Date colum, the index should be still usable while using YEAR or MONTH functions likely prevent using the index)...
Dec 19, 2013 05:58 AM|gahhon|LINK
SELECT Date FROM <TABLE> WHERE ( MONTH(Date)=@month AND YEAR(Date)=@year )
This statement is resolve my problem. Thanks AidyF :)