How to get Friday dates in a Month
try this..
declare @DateFrom datetime,@DateTo datetime
set @DateFrom='23 Mar 2014'
set @DateTo='26 Jun 2014'
;WITH CTEQuery AS (
SELECT CAST(@DateFrom AS DATETIME) AS dt
UNION ALL
SELECT DATEADD(dd, 1, dt)
FROM CTEQuery s
WHERE DATEADD(dd, 1, dt) <= CAST(@DateTo AS DATETIME)
),sampleData as(
select dt,datename(WEEKDAY,dt)as [DayName] from CTEQuery )
select * from sampleData where [DayName]='Friday'
you have to just pass @
DateFrom
and @DateTo
from code behind and you will get all friday dates between there dates..
No comments :
Post a Comment