<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Get Date of All Weekdays or Weekends of the Year</title>
	<atom:link href="http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/</link>
	<description>SQL, SQL Server, MySQL, Big Data and NoSQL</description>
	<lastBuildDate>Wed, 19 Jun 2013 08:01:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #009 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-400680</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #009 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 29 Dec 2012 01:31:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-400680</guid>
		<description><![CDATA[[...] Get Date of All Weekdays or Weekends of the Year [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Get Date of All Weekdays or Weekends of the Year [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sushil</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-94428</link>
		<dc:creator><![CDATA[Sushil]]></dc:creator>
		<pubDate>Wed, 20 Oct 2010 12:41:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-94428</guid>
		<description><![CDATA[Can Any one help how to calculate moving average monthly wise.

Charge ,Payment,	Month, AverageCharge,AveragePayment
300	100	1	300	100
500	150	2	400	125
400	200	3	300	116.6666667
200	50	4	150	62.5
800	300	5	200	70
450	100	6	208.3333333	66.66666667
600	150	7	150	35.71428571

just like we do in excel sheet.]]></description>
		<content:encoded><![CDATA[<p>Can Any one help how to calculate moving average monthly wise.</p>
<p>Charge ,Payment,	Month, AverageCharge,AveragePayment<br />
300	100	1	300	100<br />
500	150	2	400	125<br />
400	200	3	300	116.6666667<br />
200	50	4	150	62.5<br />
800	300	5	200	70<br />
450	100	6	208.3333333	66.66666667<br />
600	150	7	150	35.71428571</p>
<p>just like we do in excel sheet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-67850</link>
		<dc:creator><![CDATA[Paul]]></dc:creator>
		<pubDate>Thu, 29 Apr 2010 18:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-67850</guid>
		<description><![CDATA[Would you have any idea how to get a list of dates of the start and end of each week in a variable-specified date range?

DECLARE @RangeStartDate DATETIME, 
        @RangeEndDate   DATETIME;
        
SET @RangeStartDate = &#039;2008-03-01&#039;; 
--SELECT @RangeStartDate;
SET @RangeEndDate   = &#039;2008-05-01&#039;; 
--SELECT @RangeEndDate;]]></description>
		<content:encoded><![CDATA[<p>Would you have any idea how to get a list of dates of the start and end of each week in a variable-specified date range?</p>
<p>DECLARE @RangeStartDate DATETIME,<br />
        @RangeEndDate   DATETIME;</p>
<p>SET @RangeStartDate = &#8217;2008-03-01&#8242;;<br />
&#8211;SELECT @RangeStartDate;<br />
SET @RangeEndDate   = &#8217;2008-05-01&#8242;;<br />
&#8211;SELECT @RangeEndDate;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Gupta</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-65910</link>
		<dc:creator><![CDATA[Sachin Gupta]]></dc:creator>
		<pubDate>Wed, 21 Apr 2010 11:43:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-65910</guid>
		<description><![CDATA[This Procedure will help to get Monday in a month

CREATE PROCEDURE SP_GETMONDAYINAMONTH
@FRISTDAYOFMONTH DATETIME
AS
BEGIN
DECLARE @NOOFDAYS INT
SET @NOOFDAYS = (select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(@FRISTDAYOFMONTH) as varchar)+&#039;-&#039;+cast(month(@FRISTDAYOFMONTH) as varchar)+&#039;-01&#039; as datetime)))))
SELECT DISTINCT DATEADD(d, NUMBER, @FRISTDAYOFMONTH) AS DATE ,
CASE DATEPART(dw, DATEADD(d, NUMBER, @FRISTDAYOFMONTH))
WHEN 2 THEN &#039;MONDAY&#039;  
ELSE &#039;WORKING DAY&#039; 
END AS [DAY OF WEAK]
FROM MASTER..SPT_VALUES
WHERE NUMBER BETWEEN 0 AND @NOOFDAYS AND (DATEPART(dw, DATEADD(d, NUMBER, @FRISTDAYOFMONTH)) = 2)
ORDER BY DATEADD(d, number, @FRISTDAYOFMONTH)
END

EXEC SP_GETMONDAYINAMONTH &#039;2010-04-01&#039;

When you execute this procedure you have to pass the frist day of month in which month you want to calculate the no of Monday]]></description>
		<content:encoded><![CDATA[<p>This Procedure will help to get Monday in a month</p>
<p>CREATE PROCEDURE SP_GETMONDAYINAMONTH<br />
@FRISTDAYOFMONTH DATETIME<br />
AS<br />
BEGIN<br />
DECLARE @NOOFDAYS INT<br />
SET @NOOFDAYS = (select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(@FRISTDAYOFMONTH) as varchar)+&#8217;-'+cast(month(@FRISTDAYOFMONTH) as varchar)+&#8217;-01&#8242; as datetime)))))<br />
SELECT DISTINCT DATEADD(d, NUMBER, @FRISTDAYOFMONTH) AS DATE ,<br />
CASE DATEPART(dw, DATEADD(d, NUMBER, @FRISTDAYOFMONTH))<br />
WHEN 2 THEN &#8216;MONDAY&#8217;<br />
ELSE &#8216;WORKING DAY&#8217;<br />
END AS [DAY OF WEAK]<br />
FROM MASTER..SPT_VALUES<br />
WHERE NUMBER BETWEEN 0 AND @NOOFDAYS AND (DATEPART(dw, DATEADD(d, NUMBER, @FRISTDAYOFMONTH)) = 2)<br />
ORDER BY DATEADD(d, number, @FRISTDAYOFMONTH)<br />
END</p>
<p>EXEC SP_GETMONDAYINAMONTH &#8217;2010-04-01&#8242;</p>
<p>When you execute this procedure you have to pass the frist day of month in which month you want to calculate the no of Monday</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sachin Gupta</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-65353</link>
		<dc:creator><![CDATA[Sachin Gupta]]></dc:creator>
		<pubDate>Sat, 17 Apr 2010 06:04:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-65353</guid>
		<description><![CDATA[CREATE PROCEDURE SP_MONTH
@COUNTER INT
AS
BEGIN
DECLARE @TEMPTABLE TABLE ([MONTH NAME] VARCHAR(50), [MONTH YEAR] VARCHAR(6))
DECLARE @RESULT VARCHAR(MAX)
WHILE @COUNTER &gt; 0
BEGIN
INSERT INTO @TEMPTABLE VALUES (DATENAME(MONTH,DATEADD(MM, -@COUNTER, GETDATE())),DATEPART(YYYY, DATEADD(MM, -@COUNTER, GETDATE())))
SET @COUNTER = @COUNTER - 1
END
SELECT * FROM @TEMPTABLE
END


EXEC SP_MONTH  24

This procedure can calculate nos of month whatever u want]]></description>
		<content:encoded><![CDATA[<p>CREATE PROCEDURE SP_MONTH<br />
@COUNTER INT<br />
AS<br />
BEGIN<br />
DECLARE @TEMPTABLE TABLE ([MONTH NAME] VARCHAR(50), [MONTH YEAR] VARCHAR(6))<br />
DECLARE @RESULT VARCHAR(MAX)<br />
WHILE @COUNTER &gt; 0<br />
BEGIN<br />
INSERT INTO @TEMPTABLE VALUES (DATENAME(MONTH,DATEADD(MM, -@COUNTER, GETDATE())),DATEPART(YYYY, DATEADD(MM, -@COUNTER, GETDATE())))<br />
SET @COUNTER = @COUNTER &#8211; 1<br />
END<br />
SELECT * FROM @TEMPTABLE<br />
END</p>
<p>EXEC SP_MONTH  24</p>
<p>This procedure can calculate nos of month whatever u want</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-62669</link>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Wed, 10 Mar 2010 17:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-62669</guid>
		<description><![CDATA[Hello Kranthi,

Change the last SELECT statement of query in article as below:

SELECT FromDate AS Date, Dayname
FROM CTE
WHERE DayName IN (&#039;Monday&#039;)


Although this querywould return all mondays of current year but it can be modified to retreive records only for a month.

Regards,
Pinal Dave]]></description>
		<content:encoded><![CDATA[<p>Hello Kranthi,</p>
<p>Change the last SELECT statement of query in article as below:</p>
<p>SELECT FromDate AS Date, Dayname<br />
FROM CTE<br />
WHERE DayName IN (&#8216;Monday&#8217;)</p>
<p>Although this querywould return all mondays of current year but it can be modified to retreive records only for a month.</p>
<p>Regards,<br />
Pinal Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kranthi</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-62643</link>
		<dc:creator><![CDATA[kranthi]]></dc:creator>
		<pubDate>Wed, 10 Mar 2010 11:30:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-62643</guid>
		<description><![CDATA[hi,
 
can anybody give me the query for retriving only monday of every month]]></description>
		<content:encoded><![CDATA[<p>hi,</p>
<p>can anybody give me the query for retriving only monday of every month</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ebin Roy</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-62278</link>
		<dc:creator><![CDATA[Ebin Roy]]></dc:creator>
		<pubDate>Sat, 06 Mar 2010 01:49:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-62278</guid>
		<description><![CDATA[Hi Guys,
 Great job! Meanwhile I would like to share one good article based on CTE.

http://www.simple-talk.com/sql/t-sql-programming/sql-server-2005-common-table-expressions/

Thanks
Ebin]]></description>
		<content:encoded><![CDATA[<p>Hi Guys,<br />
 Great job! Meanwhile I would like to share one good article based on CTE.</p>
<p><a href="http://www.simple-talk.com/sql/t-sql-programming/sql-server-2005-common-table-expressions/" rel="nofollow">http://www.simple-talk.com/sql/t-sql-programming/sql-server-2005-common-table-expressions/</a></p>
<p>Thanks<br />
Ebin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manesh Joseph</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-61330</link>
		<dc:creator><![CDATA[Manesh Joseph]]></dc:creator>
		<pubDate>Wed, 17 Feb 2010 11:06:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-61330</guid>
		<description><![CDATA[Veru useful script!!]]></description>
		<content:encoded><![CDATA[<p>Veru useful script!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: senjay</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-60545</link>
		<dc:creator><![CDATA[senjay]]></dc:creator>
		<pubDate>Tue, 02 Feb 2010 09:59:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-60545</guid>
		<description><![CDATA[Hi frnds

  I have table named Holidaylist .
with columns Hid,Hname,date,month,year.I want to retrieve 
secondworking day of the current month that includes 
saturday and sunday as holidays

Provide me the solution

thankx in advance]]></description>
		<content:encoded><![CDATA[<p>Hi frnds</p>
<p>  I have table named Holidaylist .<br />
with columns Hid,Hname,date,month,year.I want to retrieve<br />
secondworking day of the current month that includes<br />
saturday and sunday as holidays</p>
<p>Provide me the solution</p>
<p>thankx in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mitesh Oswal</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-60366</link>
		<dc:creator><![CDATA[Mitesh Oswal]]></dc:creator>
		<pubDate>Fri, 29 Jan 2010 07:38:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-60366</guid>
		<description><![CDATA[DECLARE
	@weekDay	TINYINT,@daySaturday	DATETIME,@daySunday	DATETIME

SET
	@weekDay	=	DATEPART(dw,&#039;2010&#039;)

SELECT
	@daySaturday	=	DATEADD(dd,7-@weekDay,&#039;2010&#039;),
	@daySunday		=	DATEADD(dd,7-@weekDay+1,&#039;2010&#039;)


SELECT 
	DATEADD(dd,(number-1)*7,@daySaturday) &#039;SATURDAY&#039;,
	DATEADD(dd,(number-1)*7,@daySunday) &#039;SATURDAY&#039;
FROM
	dbo.tally
WHERE
	number	&lt; = 53	AND
	DATEADD(dd,(number-1)*7,@daySunday) &lt;= &#039;01/01/2011&#039;]]></description>
		<content:encoded><![CDATA[<p>DECLARE<br />
	@weekDay	TINYINT,@daySaturday	DATETIME,@daySunday	DATETIME</p>
<p>SET<br />
	@weekDay	=	DATEPART(dw,&#8217;2010&#8242;)</p>
<p>SELECT<br />
	@daySaturday	=	DATEADD(dd,7-@weekDay,&#8217;2010&#8242;),<br />
	@daySunday		=	DATEADD(dd,7-@weekDay+1,&#8217;2010&#8242;)</p>
<p>SELECT<br />
	DATEADD(dd,(number-1)*7,@daySaturday) &#8216;SATURDAY&#8217;,<br />
	DATEADD(dd,(number-1)*7,@daySunday) &#8216;SATURDAY&#8217;<br />
FROM<br />
	dbo.tally<br />
WHERE<br />
	number	&lt; = 53	AND<br />
	DATEADD(dd,(number-1)*7,@daySunday) &lt;= &#039;01/01/2011&#039;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: senjay</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59396</link>
		<dc:creator><![CDATA[senjay]]></dc:creator>
		<pubDate>Wed, 06 Jan 2010 09:40:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59396</guid>
		<description><![CDATA[thankx

 it is very helpful to query

i have another problem

DECLARE @date DATETIME;
SET @date = &#039;2006-10-15&#039;;
Select datename(MONTH,DateAdd(mm,-12,@date)),datename(year,DateAdd(mm,-12,@date)) union all
select datename(MONTH,DateAdd(mm,-11,@date)),datename(year,DateAdd(mm,-11,@date)) 

union all
select datename(MONTH,DateAdd(mm,-10,@date)),datename(year,DateAdd(mm,-10,@date)) union all
select datename(MONTH,DateAdd(mm,-09,@date)),datename(year,DateAdd(mm,-09,@date)) union all
select datename(MONTH,DateAdd(mm,-08,@date)),datename(year,DateAdd(mm,-08,@date)) union all
select datename(MONTH,DateAdd(mm,-07,@date)),datename(year,DateAdd(mm,-07,@date)) union all
select datename(MONTH,DateAdd(mm,-06,@date)),datename(year,DateAdd(mm,-06,@date)) union all
select datename(MONTH,DateAdd(mm,-05,@date)),datename(year,DateAdd(mm,-05,@date)) union all
select datename(MONTH,DateAdd(mm,-04,@date)),datename(year,DateAdd(mm,-04,@date)) union all
select datename(MONTH,DateAdd(mm,-03,@date)),datename(year,DateAdd(mm,-03,@date)) union all
select datename(MONTH,DateAdd(mm,-02,@date)),datename(year,DateAdd(mm,-02,@date)) union all
select datename(MONTH,DateAdd(mm,-01,@date)),datename(year,DateAdd(mm,-01,@date))
This is the query that retrieves data for past one year with month .
But if we want to retrieve more than past 24 months and more its not easier to query.

Is there any other solution for this comments]]></description>
		<content:encoded><![CDATA[<p>thankx</p>
<p> it is very helpful to query</p>
<p>i have another problem</p>
<p>DECLARE @date DATETIME;<br />
SET @date = &#8217;2006-10-15&#8242;;<br />
Select datename(MONTH,DateAdd(mm,-12,@date)),datename(year,DateAdd(mm,-12,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-11,@date)),datename(year,DateAdd(mm,-11,@date)) </p>
<p>union all<br />
select datename(MONTH,DateAdd(mm,-10,@date)),datename(year,DateAdd(mm,-10,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-09,@date)),datename(year,DateAdd(mm,-09,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-08,@date)),datename(year,DateAdd(mm,-08,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-07,@date)),datename(year,DateAdd(mm,-07,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-06,@date)),datename(year,DateAdd(mm,-06,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-05,@date)),datename(year,DateAdd(mm,-05,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-04,@date)),datename(year,DateAdd(mm,-04,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-03,@date)),datename(year,DateAdd(mm,-03,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-02,@date)),datename(year,DateAdd(mm,-02,@date)) union all<br />
select datename(MONTH,DateAdd(mm,-01,@date)),datename(year,DateAdd(mm,-01,@date))<br />
This is the query that retrieves data for past one year with month .<br />
But if we want to retrieve more than past 24 months and more its not easier to query.</p>
<p>Is there any other solution for this comments</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: senjay</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59380</link>
		<dc:creator><![CDATA[senjay]]></dc:creator>
		<pubDate>Wed, 06 Jan 2010 04:23:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59380</guid>
		<description><![CDATA[hai


 can anybody give me the query for retriving previous year and month details.]]></description>
		<content:encoded><![CDATA[<p>hai</p>
<p> can anybody give me the query for retriving previous year and month details.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shan</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59210</link>
		<dc:creator><![CDATA[Shan]]></dc:creator>
		<pubDate>Thu, 31 Dec 2009 14:32:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59210</guid>
		<description><![CDATA[Thanks Pinal for your detailed reply, appreciate it.

-Shan]]></description>
		<content:encoded><![CDATA[<p>Thanks Pinal for your detailed reply, appreciate it.</p>
<p>-Shan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59151</link>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Wed, 30 Dec 2009 17:54:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59151</guid>
		<description><![CDATA[Hi Shan,

MAXRECURSION query hint in common table expression is used to recursively execute the last statement in CTE that is joined using UNION, UNION ALL, INTERSECT or EXCEPT.
Here The number 370 is used to keep recursion under the number of days in a year (365).

Regards,
Pinal Dave]]></description>
		<content:encoded><![CDATA[<p>Hi Shan,</p>
<p>MAXRECURSION query hint in common table expression is used to recursively execute the last statement in CTE that is joined using UNION, UNION ALL, INTERSECT or EXCEPT.<br />
Here The number 370 is used to keep recursion under the number of days in a year (365).</p>
<p>Regards,<br />
Pinal Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59142</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Wed, 30 Dec 2009 14:01:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59142</guid>
		<description><![CDATA[Pinal,

It wont work in non-English servers
So better usage is

SELECT FromDate AS Date, Dayname
FROM CTE
WHERE datepart(weekday,Fromdate) in (7,1)]]></description>
		<content:encoded><![CDATA[<p>Pinal,</p>
<p>It wont work in non-English servers<br />
So better usage is</p>
<p>SELECT FromDate AS Date, Dayname<br />
FROM CTE<br />
WHERE datepart(weekday,Fromdate) in (7,1)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahul Bhargava</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59129</link>
		<dc:creator><![CDATA[Rahul Bhargava]]></dc:creator>
		<pubDate>Wed, 30 Dec 2009 09:07:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59129</guid>
		<description><![CDATA[Hi dba guy,
Your query is very nice to understand .but i have one doubt is that you used master..spt_values just for getting numbers from 0 to 364 or there is any other specific reason.
Thanks
Rahul]]></description>
		<content:encoded><![CDATA[<p>Hi dba guy,<br />
Your query is very nice to understand .but i have one doubt is that you used master..spt_values just for getting numbers from 0 to 364 or there is any other specific reason.<br />
Thanks<br />
Rahul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shan</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59105</link>
		<dc:creator><![CDATA[Shan]]></dc:creator>
		<pubDate>Tue, 29 Dec 2009 14:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59105</guid>
		<description><![CDATA[Hi,  This is great script and will be helpful in multiple ocassions (espically when join with my time dimension), But i have one question though.

Can some one explain me how 
OPTION (MAXRECURSION 370); works?, Also how do you arrive at this number - 370. I am trying to understand from BoL but still not able to get it. Any help in this regard with be great.]]></description>
		<content:encoded><![CDATA[<p>Hi,  This is great script and will be helpful in multiple ocassions (espically when join with my time dimension), But i have one question though.</p>
<p>Can some one explain me how<br />
OPTION (MAXRECURSION 370); works?, Also how do you arrive at this number &#8211; 370. I am trying to understand from BoL but still not able to get it. Any help in this regard with be great.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Ballantyne</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59101</link>
		<dc:creator><![CDATA[Dave Ballantyne]]></dc:creator>
		<pubDate>Tue, 29 Dec 2009 13:45:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59101</guid>
		<description><![CDATA[Personally, i prefer to use a Calendar table for this sort of operation.]]></description>
		<content:encoded><![CDATA[<p>Personally, i prefer to use a Calendar table for this sort of operation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abdul Majid</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59080</link>
		<dc:creator><![CDATA[Abdul Majid]]></dc:creator>
		<pubDate>Tue, 29 Dec 2009 06:27:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59080</guid>
		<description><![CDATA[Really very usefull scripts...!]]></description>
		<content:encoded><![CDATA[<p>Really very usefull scripts&#8230;!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ritesh Shah</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59077</link>
		<dc:creator><![CDATA[Ritesh Shah]]></dc:creator>
		<pubDate>Tue, 29 Dec 2009 05:08:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59077</guid>
		<description><![CDATA[Good Script Tejas!!!.

When talk comes to date script, I would also like to share one of the script to find out first and last Friday of the years. starting from Jan-06 to Dec-2020. Actually I have got this request from one of the forums and created this very quickly.

WITH CTE AS
(
select CONVERT(datetime,&#039;01/06/2006&#039;) as dt,  datename(dw,CONVERT(datetime,&#039;01/06/2006&#039;)) as dy,datename(mm,CONVERT(datetime,&#039;01/06/2006&#039;)) as mn, YEAR(CONVERT(datetime,&#039;01/06/2006&#039;)) AS yr
union all
select s.dt+7 as dts,datename(dw,dt+7) as dy  ,datename(mm,dt+7) as dy, YEAR(dt+7) AS yr
from cte s
where s.dt&lt;CONVERT(datetime,&#039;12/31/2020&#039;)
)
select MAX(dt) as dt,dy,mn,yr from cte
group by dy,mn,yr
UNION
select MIN(dt) as dt,dy,mn,yr from cte
group by dy,mn,yr
ORDER BY dt
OPTION (MaxRecursion 0)]]></description>
		<content:encoded><![CDATA[<p>Good Script Tejas!!!.</p>
<p>When talk comes to date script, I would also like to share one of the script to find out first and last Friday of the years. starting from Jan-06 to Dec-2020. Actually I have got this request from one of the forums and created this very quickly.</p>
<p>WITH CTE AS<br />
(<br />
select CONVERT(datetime,&#8217;01/06/2006&#8242;) as dt,  datename(dw,CONVERT(datetime,&#8217;01/06/2006&#8242;)) as dy,datename(mm,CONVERT(datetime,&#8217;01/06/2006&#8242;)) as mn, YEAR(CONVERT(datetime,&#8217;01/06/2006&#8242;)) AS yr<br />
union all<br />
select s.dt+7 as dts,datename(dw,dt+7) as dy  ,datename(mm,dt+7) as dy, YEAR(dt+7) AS yr<br />
from cte s<br />
where s.dt&lt;CONVERT(datetime,&#039;12/31/2020&#039;)<br />
)<br />
select MAX(dt) as dt,dy,mn,yr from cte<br />
group by dy,mn,yr<br />
UNION<br />
select MIN(dt) as dt,dy,mn,yr from cte<br />
group by dy,mn,yr<br />
ORDER BY dt<br />
OPTION (MaxRecursion 0)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dba guy</title>
		<link>http://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/#comment-59074</link>
		<dc:creator><![CDATA[dba guy]]></dc:creator>
		<pubDate>Tue, 29 Dec 2009 03:00:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7648#comment-59074</guid>
		<description><![CDATA[Well done but we don&#039;t need to use recursive
Here&#039;s my script with the same result
----------------------------------------------------
DECLARE @FirstDateOfYear DATETIME
SET @FirstDateOfYear = &#039;2010-01-01&#039;
SELECT DISTINCT DATEADD(d, number, @FirstDateOfYear), 
		CASE DATEPART(dw, DATEADD(d, number, @FirstDateOfYear)) 
			WHEN 7 THEN &#039;Saturday&#039;
			WHEN 1 THEN &#039;Sunday&#039;
			ELSE &#039;Work Day&#039;
		END
FROM master..spt_values
WHERE number BETWEEN 0 AND 364
	AND (DATEPART(dw, DATEADD(d, number, @FirstDateOfYear)) = 1 OR DATEPART(dw, DATEADD(d, number, @FirstDateOfYear)) = 7)
ORDER BY DATEADD(d, number, @FirstDateOfYear)]]></description>
		<content:encoded><![CDATA[<p>Well done but we don&#8217;t need to use recursive<br />
Here&#8217;s my script with the same result<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
DECLARE @FirstDateOfYear DATETIME<br />
SET @FirstDateOfYear = &#8217;2010-01-01&#8242;<br />
SELECT DISTINCT DATEADD(d, number, @FirstDateOfYear),<br />
		CASE DATEPART(dw, DATEADD(d, number, @FirstDateOfYear))<br />
			WHEN 7 THEN &#8216;Saturday&#8217;<br />
			WHEN 1 THEN &#8216;Sunday&#8217;<br />
			ELSE &#8216;Work Day&#8217;<br />
		END<br />
FROM master..spt_values<br />
WHERE number BETWEEN 0 AND 364<br />
	AND (DATEPART(dw, DATEADD(d, number, @FirstDateOfYear)) = 1 OR DATEPART(dw, DATEADD(d, number, @FirstDateOfYear)) = 7)<br />
ORDER BY DATEADD(d, number, @FirstDateOfYear)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
