<?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; Find Weekend and Weekdays from Datetime in SQL Server 2012</title>
	<atom:link href="http://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Nav</title>
		<link>http://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/#comment-465746</link>
		<dc:creator><![CDATA[Nav]]></dc:creator>
		<pubDate>Sun, 28 Apr 2013 20:57:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21699#comment-465746</guid>
		<description><![CDATA[Hi,

I need quick help.

I want to write a function which will take today&#039;s date and reply me the number of weekdays only. For e.g. today is 04-28-2013. Result should be 20. How ?? today&#039;s date minus 8 days as weekend passed. If today&#039;s date is 0-17-2013 then result should be 12.

Catch is to know how many weekends are passed from today&#039;s date. I need to calculate dynamic everyday.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I need quick help.</p>
<p>I want to write a function which will take today&#8217;s date and reply me the number of weekdays only. For e.g. today is 04-28-2013. Result should be 20. How ?? today&#8217;s date minus 8 days as weekend passed. If today&#8217;s date is 0-17-2013 then result should be 12.</p>
<p>Catch is to know how many weekends are passed from today&#8217;s date. I need to calculate dynamic everyday.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frobozz</title>
		<link>http://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/#comment-441704</link>
		<dc:creator><![CDATA[Frobozz]]></dc:creator>
		<pubDate>Thu, 21 Mar 2013 16:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21699#comment-441704</guid>
		<description><![CDATA[&quot;I assume most of us are using SQL Server 2012...&quot;

Evidently you don&#039;t guys work in the real world. Do you also assume that most of us are using Windows 8?]]></description>
		<content:encoded><![CDATA[<p>&#8220;I assume most of us are using SQL Server 2012&#8230;&#8221;</p>
<p>Evidently you don&#8217;t guys work in the real world. Do you also assume that most of us are using Windows 8?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Singfield</title>
		<link>http://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/#comment-387978</link>
		<dc:creator><![CDATA[Alan Singfield]]></dc:creator>
		<pubDate>Thu, 06 Dec 2012 09:33:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21699#comment-387978</guid>
		<description><![CDATA[This has a flaw in it in that it doesn&#039;t consider the setting of @@DATEFIRST. In the US, they number Sunday as 1, Monday as 2 etc. Most other countries use Monday as 1, Tuesday as 2.

This can be changed with the SET DATEFIRST command.

Here&#039;s my attempt, it will give consistent results whatever the setting of @@DATEFIRST is:

SELECT	today = datemaker.date,
		name = DATENAME(dw, datemaker.date),
		daynumber = 1 + ((DATEPART(dw, datemaker.date) + @@DATEFIRST - 2) % 7)
FROM (
	-- Make a list of dates starting from tomorrow
	SELECT TOP 21
			date = DATEADD(d, ROW_NUMBER() OVER (ORDER BY id), CONVERT(date, GETDATE()))
	FROM	sys.sysobjects
) datemaker]]></description>
		<content:encoded><![CDATA[<p>This has a flaw in it in that it doesn&#8217;t consider the setting of @@DATEFIRST. In the US, they number Sunday as 1, Monday as 2 etc. Most other countries use Monday as 1, Tuesday as 2.</p>
<p>This can be changed with the SET DATEFIRST command.</p>
<p>Here&#8217;s my attempt, it will give consistent results whatever the setting of @@DATEFIRST is:</p>
<p>SELECT	today = datemaker.date,<br />
		name = DATENAME(dw, datemaker.date),<br />
		daynumber = 1 + ((DATEPART(dw, datemaker.date) + @@DATEFIRST &#8211; 2) % 7)<br />
FROM (<br />
	&#8211; Make a list of dates starting from tomorrow<br />
	SELECT TOP 21<br />
			date = DATEADD(d, ROW_NUMBER() OVER (ORDER BY id), CONVERT(date, GETDATE()))<br />
	FROM	sys.sysobjects<br />
) datemaker</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaileshgothal</title>
		<link>http://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/#comment-382433</link>
		<dc:creator><![CDATA[shaileshgothal]]></dc:creator>
		<pubDate>Wed, 28 Nov 2012 08:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21699#comment-382433</guid>
		<description><![CDATA[hi 

we can use the following code also in SQL 

SELECT CATEGORY =
CASE (DATENAME(DW,GETDATE()))
WHEN  &#039;SATURDAY&#039; THEN &#039;WEEKEND&#039;
WHEN  &#039;SUNDAY&#039; THEN &#039;WEEKEND&#039;
ELSE &#039;WEEKDAY&#039;
END]]></description>
		<content:encoded><![CDATA[<p>hi </p>
<p>we can use the following code also in SQL </p>
<p>SELECT CATEGORY =<br />
CASE (DATENAME(DW,GETDATE()))<br />
WHEN  &#8216;SATURDAY&#8217; THEN &#8216;WEEKEND&#8217;<br />
WHEN  &#8216;SUNDAY&#8217; THEN &#8216;WEEKEND&#8217;<br />
ELSE &#8216;WEEKDAY&#8217;<br />
END</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Girijesh</title>
		<link>http://blog.sqlauthority.com/2012/11/25/sql-server-find-weekend-and-weekdays-from-datetime-in-sql-server-2012/#comment-380469</link>
		<dc:creator><![CDATA[Girijesh]]></dc:creator>
		<pubDate>Sun, 25 Nov 2012 06:38:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21699#comment-380469</guid>
		<description><![CDATA[Nice solution!]]></description>
		<content:encoded><![CDATA[<p>Nice solution!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
