<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cyberpunk &#187; T-SQL</title>
	<atom:link href="http://punk.tw/tag/t-sql/feed" rel="self" type="application/rss+xml" />
	<link>http://punk.tw</link>
	<description>網際叛客：學習心得、Web 2.0與網路觀察、Google應用與技術、Ruby on Rails, Google App Engine</description>
	<lastBuildDate>Mon, 29 Nov 2010 06:35:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Transact-SQL: DATEPART</title>
		<link>http://punk.tw/2007/10/09/teansact-sql-datepart</link>
		<comments>http://punk.tw/2007/10/09/teansact-sql-datepart#comments</comments>
		<pubDate>Mon, 08 Oct 2007 11:33:28 +0000</pubDate>
		<dc:creator>deduce</dc:creator>
				<category><![CDATA[程式設計]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://punk.tw/2007/10/09/345.html</guid>
		<description><![CDATA[直接使用SQL語法就可以在資料庫裡面對資料事先進行很多的處理與篩選，例如要取出時間屬於星期一到五的資料，我們可以利用DATEPART這個函數來處理： SELECT * FROM posts WHERE DATEPART(weekday, date) BETWEEN 2 AND 6 DATEPART函數裡面第一個參數代表要parse出怎樣的資料、第二個參數則是欄位的名稱。第一個參數有下列選擇： year傳回年份 quarter傳回第n季 month傳回月份 dayofyear傳回一年之中的第幾天 day傳回天數 week傳回週數 weekday傳回星期幾 （星期日是1，星期一是2....星期六是7） hour傳回小時 minute傳回分鐘 second傳回秒數 millisecond Reference http://technet.microsoft.com/zh-tw/library/ms174420.aspx]]></description>
			<content:encoded><![CDATA[<p>直接使用SQL語法就可以在資料庫裡面對資料事先進行很多的處理與篩選，例如要取出時間屬於星期一到五的資料，我們可以利用DATEPART這個函數來處理：</p>
<p>
<pre class="prettyprint">SELECT * FROM posts WHERE DATEPART(weekday, date) BETWEEN 2 AND 6</pre>
</p>
<p>DATEPART函數裡面第一個參數代表要parse出怎樣的資料、第二個參數則是欄位的名稱。第一個參數有下列選擇：</p>
<ul>
<li>year傳回年份
<li>quarter傳回第n季
<li>month傳回月份
<li>dayofyear傳回一年之中的第幾天
<li>day傳回天數
<li>week傳回週數
<li>weekday傳回星期幾 （星期日是1，星期一是2....星期六是7）
<li>hour傳回小時
<li>minute傳回分鐘
<li>second傳回秒數
<li>millisecond</li>
</ul>
<h1>Reference</h1>
<p><a title="http://technet.microsoft.com/zh-tw/library/ms174420.aspx" href="http://technet.microsoft.com/zh-tw/library/ms174420.aspx">http://technet.microsoft.com/zh-tw/library/ms174420.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://punk.tw/2007/10/09/teansact-sql-datepart/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

