<?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; Few Useful DateTime Functions to Find Specific Dates</title>
	<atom:link href="http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 10 Feb 2012 02:12:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: RenaT</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-249105</link>
		<dc:creator><![CDATA[RenaT]]></dc:creator>
		<pubDate>Mon, 06 Feb 2012 19:49:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-249105</guid>
		<description><![CDATA[Just wondering how to incorporate a month end split. I want to use the weeks as listed above, but if the &#039;Wednesday&#039; is the end of the month, I want to see that day instead of the last day of the week (instead of Saturday). My groups are already set, now I am just working on the labels, which is where my problem is occuring.
thanks in advance]]></description>
		<content:encoded><![CDATA[<p>Just wondering how to incorporate a month end split. I want to use the weeks as listed above, but if the &#8216;Wednesday&#8217; is the end of the month, I want to see that day instead of the last day of the week (instead of Saturday). My groups are already set, now I am just working on the labels, which is where my problem is occuring.<br />
thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wilma</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-235275</link>
		<dc:creator><![CDATA[Wilma]]></dc:creator>
		<pubDate>Wed, 11 Jan 2012 12:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-235275</guid>
		<description><![CDATA[Thank you very much for this post, it saved me a lot of time!]]></description>
		<content:encoded><![CDATA[<p>Thank you very much for this post, it saved me a lot of time!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srinath</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-227223</link>
		<dc:creator><![CDATA[srinath]]></dc:creator>
		<pubDate>Wed, 28 Dec 2011 06:04:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-227223</guid>
		<description><![CDATA[Hi, Any body can tell me that how to find last sunday date of the current month and next month.]]></description>
		<content:encoded><![CDATA[<p>Hi, Any body can tell me that how to find last sunday date of the current month and next month.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-221985</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 20 Dec 2011 09:32:05 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-221985</guid>
		<description><![CDATA[Start with this

select dateadd(day,number,&#039;20001010&#039;) as dates from master..spt_values
where type=&#039;p&#039; order by number]]></description>
		<content:encoded><![CDATA[<p>Start with this</p>
<p>select dateadd(day,number,&#8217;20001010&#8242;) as dates from master..spt_values<br />
where type=&#8217;p&#8217; order by number</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LA</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-221865</link>
		<dc:creator><![CDATA[LA]]></dc:creator>
		<pubDate>Tue, 20 Dec 2011 05:53:39 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-221865</guid>
		<description><![CDATA[I liked the ideas in this post. Just another question. My client start the new month on the 26th day. e.g. 26 December 2011 = 1 January 2012 = first day of month January 2012.
Do anyone know a quick way to calculate these dates.
What I intend doing is to have a date lookup table where the ID is 20111226, the date is 26/12/2011 and the financial date is 1 January 2012.
I need to populate the table from 1 Jan 2000 to 31 Dec 2050

Any ideas?]]></description>
		<content:encoded><![CDATA[<p>I liked the ideas in this post. Just another question. My client start the new month on the 26th day. e.g. 26 December 2011 = 1 January 2012 = first day of month January 2012.<br />
Do anyone know a quick way to calculate these dates.<br />
What I intend doing is to have a date lookup table where the ID is 20111226, the date is 26/12/2011 and the financial date is 1 January 2012.<br />
I need to populate the table from 1 Jan 2000 to 31 Dec 2050</p>
<p>Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swapan</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-196099</link>
		<dc:creator><![CDATA[Swapan]]></dc:creator>
		<pubDate>Tue, 15 Nov 2011 14:17:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-196099</guid>
		<description><![CDATA[awesome. helped to recapitulate. understand the logic and it is as easy as abc.]]></description>
		<content:encoded><![CDATA[<p>awesome. helped to recapitulate. understand the logic and it is as easy as abc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ak</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-194222</link>
		<dc:creator><![CDATA[ak]]></dc:creator>
		<pubDate>Sun, 13 Nov 2011 02:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-194222</guid>
		<description><![CDATA[column--weekday as sun,mon,tue...
             dayofmonth as 1,2,3,4,...31
             businessday as 0 and 1.if 0 holiday,1 as business day]]></description>
		<content:encoded><![CDATA[<p>column&#8211;weekday as sun,mon,tue&#8230;<br />
             dayofmonth as 1,2,3,4,&#8230;31<br />
             businessday as 0 and 1.if 0 holiday,1 as business day</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ak</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-194218</link>
		<dc:creator><![CDATA[ak]]></dc:creator>
		<pubDate>Sun, 13 Nov 2011 02:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-194218</guid>
		<description><![CDATA[how to query--
 businessDate = 1 Business day prior to the 10th of each month
if  date is Tuesday 1/10 then businessdate=1/9 which is monday
but if date is sunday 1/10,sunday is not business day so prior to business day,bsiness date=thursday.(prior to busness day friday)]]></description>
		<content:encoded><![CDATA[<p>how to query&#8211;<br />
 businessDate = 1 Business day prior to the 10th of each month<br />
if  date is Tuesday 1/10 then businessdate=1/9 which is monday<br />
but if date is sunday 1/10,sunday is not business day so prior to business day,bsiness date=thursday.(prior to busness day friday)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-190344</link>
		<dc:creator><![CDATA[Vincent]]></dc:creator>
		<pubDate>Mon, 07 Nov 2011 20:47:55 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-190344</guid>
		<description><![CDATA[great article, very helpful thank you.]]></description>
		<content:encoded><![CDATA[<p>great article, very helpful thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-168408</link>
		<dc:creator><![CDATA[George]]></dc:creator>
		<pubDate>Thu, 15 Sep 2011 16:05:33 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-168408</guid>
		<description><![CDATA[This is just perfect my friend. Really helpfull. Thanks, George from Buenos Aires.]]></description>
		<content:encoded><![CDATA[<p>This is just perfect my friend. Really helpfull. Thanks, George from Buenos Aires.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C.Willy</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-153828</link>
		<dc:creator><![CDATA[C.Willy]]></dc:creator>
		<pubDate>Thu, 04 Aug 2011 21:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-153828</guid>
		<description><![CDATA[SELECT DATEADD(Day, 0, DATEDIFF(Day, 0, GetDate()))  will give me at midnight last night.

If I would like to have the time set-up to be 11:30 p.m., (23 hours ahead), what SQL statement should I use?

Thanks.]]></description>
		<content:encoded><![CDATA[<p>SELECT DATEADD(Day, 0, DATEDIFF(Day, 0, GetDate()))  will give me at midnight last night.</p>
<p>If I would like to have the time set-up to be 11:30 p.m., (23 hours ahead), what SQL statement should I use?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Muzzy</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-151108</link>
		<dc:creator><![CDATA[Jeff Muzzy]]></dc:creator>
		<pubDate>Wed, 27 Jul 2011 18:03:08 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-151108</guid>
		<description><![CDATA[----Today
 SELECT GetUTCDate() &#039;UTC Time&#039;]]></description>
		<content:encoded><![CDATA[<p>&#8212;-Today<br />
 SELECT GetUTCDate() &#8216;UTC Time&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Muzzy</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-150890</link>
		<dc:creator><![CDATA[Jeff Muzzy]]></dc:creator>
		<pubDate>Tue, 26 Jul 2011 22:28:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-150890</guid>
		<description><![CDATA[Hi Sure, 
(Brian, I think this might answer you pivot question as well).

You question seems to be way off topic.  What you are looking for is not a date function but take a look at this articles about pivot tables, dynamic columns, and one or two other methods to implement what you are looking for.  Basically you are trying to do group by
  cast(year(dtSale) as varchar(5))+&#039;-Q&#039; 
    + cast(datepart(qq, dtSale) as varchar)
which give you the format YYYY-Qn

My solution uses computed columns, and give you a running total for the quarter.  The quarter is a bit messy to give you YYYY-Qn format but it works.
Standard disclaimer applies this hasn&#039;t been tested against a large sample size for query performance, blah, blah.

Here is a the code to what you want.  Again I would do research on what you trying to do with pivot tables.  

FYI,
jeff
------



-- drop table #prodTest; 
 create table #prodTest
 (
  id int identity(1,1),
  stProduct_name varchar(150) NOT NULL,
  stProduct_catagory varchar(80) NOT NULL,
  mnPriceUnit money,
  nQuantity int,
  -- computed column
  mnPriceSale as (nQuantity * mnPriceUnit),
  dtSale datetime NOT NULL default getdate(),
  -- use money cause in your example it would get to big too quick with decimal
 );



/* 
-- using sql one insert to multiple rows.
--   if you are using sql 2005 then do the select union all to 
--   make it work
*/

-- drop table #prodTest
insert into #prodTest 
  (
    stProduct_name, 
    stProduct_catagory,
    mnPriceUnit,
    nQuantity, 
    dtSale
  )

VALUES     
 (&#039;Nokia C7&#039;,    5, 18000.00, 1,  &#039;5/22/2010&#039;),
 (&#039;Iron Box&#039;,    4, 2000.00,  1,  &#039;1/31/2010&#039;),
 (&#039;Dell Laptop&#039;, 3, 30000.00, 1,  &#039;7/18/2010&#039;),
 (&#039;Rice&#039;,        1, 600.00,   4,  &#039;9/28/2010&#039;),
 (&#039;5 HP Printer&#039;,3, 5000.00,  3,  &#039;11/26/2010&#039;),
 (&#039;Horlicks&#039;,    1, 150.00,   1,  &#039;2/15/2010&#039;),
 (&#039;HP Laptop&#039;,   3, 30000.00, 1,  &#039;7/18/2010&#039;);
  

	SELECT * FROM #prodTest order by dtSale desc;


select 
 -- this gets your YYYY-Qn Format
 --
    cast(year(dtSale) as varchar(5))+&#039;-Q&#039; 
    + cast(datepart(qq, dtSale) as varchar) as [Year_Quarter],

 -- now create a table you want
    sum(case when stProduct_catagory=&#039;1&#039; then mnPriceSale else 0 end) as [Home],
    sum(case when stProduct_catagory=&#039;2&#039; then mnPriceSale else 0 end) as [Business],
    sum(case when stProduct_catagory=&#039;3&#039; then mnPriceSale else 0 end) as [Computers],
    sum(case when stProduct_catagory=&#039;4&#039; then mnPriceSale else 0 end) as [Electronics],
    sum(case when stProduct_catagory=&#039;5&#039; then mnPriceSale else 0 end) as [Mobiles],
    sum(mnPriceSale) as [Quarter_Total]
from
  #prodTest
group by
  cast(year(dtSale) as varchar(5))+&#039;-Q&#039; 
    + cast(datepart(qq, dtSale) as varchar)
order by
  Year_Quarter desc;]]></description>
		<content:encoded><![CDATA[<p>Hi Sure,<br />
(Brian, I think this might answer you pivot question as well).</p>
<p>You question seems to be way off topic.  What you are looking for is not a date function but take a look at this articles about pivot tables, dynamic columns, and one or two other methods to implement what you are looking for.  Basically you are trying to do group by<br />
  cast(year(dtSale) as varchar(5))+&#8217;-Q&#8217;<br />
    + cast(datepart(qq, dtSale) as varchar)<br />
which give you the format YYYY-Qn</p>
<p>My solution uses computed columns, and give you a running total for the quarter.  The quarter is a bit messy to give you YYYY-Qn format but it works.<br />
Standard disclaimer applies this hasn&#8217;t been tested against a large sample size for query performance, blah, blah.</p>
<p>Here is a the code to what you want.  Again I would do research on what you trying to do with pivot tables.  </p>
<p>FYI,<br />
jeff<br />
&#8212;&#8212;</p>
<p>&#8211; drop table #prodTest;<br />
 create table #prodTest<br />
 (<br />
  id int identity(1,1),<br />
  stProduct_name varchar(150) NOT NULL,<br />
  stProduct_catagory varchar(80) NOT NULL,<br />
  mnPriceUnit money,<br />
  nQuantity int,<br />
  &#8212; computed column<br />
  mnPriceSale as (nQuantity * mnPriceUnit),<br />
  dtSale datetime NOT NULL default getdate(),<br />
  &#8212; use money cause in your example it would get to big too quick with decimal<br />
 );</p>
<p>/*<br />
&#8211; using sql one insert to multiple rows.<br />
&#8211;   if you are using sql 2005 then do the select union all to<br />
&#8211;   make it work<br />
*/</p>
<p>&#8211; drop table #prodTest<br />
insert into #prodTest<br />
  (<br />
    stProduct_name,<br />
    stProduct_catagory,<br />
    mnPriceUnit,<br />
    nQuantity,<br />
    dtSale<br />
  )</p>
<p>VALUES<br />
 (&#8216;Nokia C7&#8242;,    5, 18000.00, 1,  &#8217;5/22/2010&#8242;),<br />
 (&#8216;Iron Box&#8217;,    4, 2000.00,  1,  &#8217;1/31/2010&#8242;),<br />
 (&#8216;Dell Laptop&#8217;, 3, 30000.00, 1,  &#8217;7/18/2010&#8242;),<br />
 (&#8216;Rice&#8217;,        1, 600.00,   4,  &#8217;9/28/2010&#8242;),<br />
 (&#8217;5 HP Printer&#8217;,3, 5000.00,  3,  &#8217;11/26/2010&#8242;),<br />
 (&#8216;Horlicks&#8217;,    1, 150.00,   1,  &#8217;2/15/2010&#8242;),<br />
 (&#8216;HP Laptop&#8217;,   3, 30000.00, 1,  &#8217;7/18/2010&#8242;);</p>
<p>	SELECT * FROM #prodTest order by dtSale desc;</p>
<p>select<br />
 &#8212; this gets your YYYY-Qn Format<br />
 &#8211;<br />
    cast(year(dtSale) as varchar(5))+&#8217;-Q&#8217;<br />
    + cast(datepart(qq, dtSale) as varchar) as [Year_Quarter],</p>
<p> &#8212; now create a table you want<br />
    sum(case when stProduct_catagory=&#8217;1&#8242; then mnPriceSale else 0 end) as [Home],<br />
    sum(case when stProduct_catagory=&#8217;2&#8242; then mnPriceSale else 0 end) as [Business],<br />
    sum(case when stProduct_catagory=&#8217;3&#8242; then mnPriceSale else 0 end) as [Computers],<br />
    sum(case when stProduct_catagory=&#8217;4&#8242; then mnPriceSale else 0 end) as [Electronics],<br />
    sum(case when stProduct_catagory=&#8217;5&#8242; then mnPriceSale else 0 end) as [Mobiles],<br />
    sum(mnPriceSale) as [Quarter_Total]<br />
from<br />
  #prodTest<br />
group by<br />
  cast(year(dtSale) as varchar(5))+&#8217;-Q&#8217;<br />
    + cast(datepart(qq, dtSale) as varchar)<br />
order by<br />
  Year_Quarter desc;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sure</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-150784</link>
		<dc:creator><![CDATA[Sure]]></dc:creator>
		<pubDate>Tue, 26 Jul 2011 11:26:49 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-150784</guid>
		<description><![CDATA[Product Sales Report
ID	Pro_Name	Pro_Cost	No. Of Units	Bill 	Pro_Cat_ ID	Date
1	Nokia C7	18000.00	1	18000.00	5	5/22/2010
2	Iron Box	2000.00	1	2000.00	4	1/31/2010
3	Dell Laptop	30000.00	1	30000.00	3	7/18/2010
4	Rice 	600.00	4	2400.00	1	9/28/2010
5	HP Printer	5000.00	1	5000.00	3	11/26/2010
6	Horlicks	150.00	1	150.00	1	2/15/2010
7	HP Laptop	30000.00	1	30000.00	3	7/18/2010

Product Category Table

Pro_Cat_ ID	Pro_Cat_Name
1	Home 
2	Business
3	Computers
4	Electronics
5	Mobiles
Expected output

Quarter	Home	Business	Computers	Electronics	Mobiles
Q1	-	-	-	2,000.00	-
Q2	150	-	-	-	18,000.00
Q3	2,400.00	-	60,000.00	-	-
Q4	-	-	5,000.00	-	-

How can i do that?]]></description>
		<content:encoded><![CDATA[<p>Product Sales Report<br />
ID	Pro_Name	Pro_Cost	No. Of Units	Bill 	Pro_Cat_ ID	Date<br />
1	Nokia C7	18000.00	1	18000.00	5	5/22/2010<br />
2	Iron Box	2000.00	1	2000.00	4	1/31/2010<br />
3	Dell Laptop	30000.00	1	30000.00	3	7/18/2010<br />
4	Rice 	600.00	4	2400.00	1	9/28/2010<br />
5	HP Printer	5000.00	1	5000.00	3	11/26/2010<br />
6	Horlicks	150.00	1	150.00	1	2/15/2010<br />
7	HP Laptop	30000.00	1	30000.00	3	7/18/2010</p>
<p>Product Category Table</p>
<p>Pro_Cat_ ID	Pro_Cat_Name<br />
1	Home<br />
2	Business<br />
3	Computers<br />
4	Electronics<br />
5	Mobiles<br />
Expected output</p>
<p>Quarter	Home	Business	Computers	Electronics	Mobiles<br />
Q1	-	-	-	2,000.00	-<br />
Q2	150	-	-	-	18,000.00<br />
Q3	2,400.00	-	60,000.00	-	-<br />
Q4	-	-	5,000.00	-	-</p>
<p>How can i do that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-146170</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 05 Jul 2011 14:35:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-146170</guid>
		<description><![CDATA[Yes you can use but make sure to use unambigious format YYYYMMDD. Read this for more information http://beyondrelational.com/blogs/madhivanan/archive/2010/06/21/understanding-datetime-column-part-ii.aspx]]></description>
		<content:encoded><![CDATA[<p>Yes you can use but make sure to use unambigious format YYYYMMDD. Read this for more information <a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/06/21/understanding-datetime-column-part-ii.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2010/06/21/understanding-datetime-column-part-ii.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-138159</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 01 Jun 2011 08:51:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-138159</guid>
		<description><![CDATA[The examples posted in this blog post will show you how to use that way in the where clause 
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx]]></description>
		<content:encoded><![CDATA[<p>The examples posted in this blog post will show you how to use that way in the where clause<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-138158</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 01 Jun 2011 08:50:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-138158</guid>
		<description><![CDATA[Please refer this post for more informations
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx]]></description>
		<content:encoded><![CDATA[<p>Please refer this post for more informations<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-138157</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 01 Jun 2011 08:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-138157</guid>
		<description><![CDATA[The following will also help you 
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx]]></description>
		<content:encoded><![CDATA[<p>The following will also help you<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2010/06/03/understanding-datetime-column-part-iii.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-136645</link>
		<dc:creator><![CDATA[Brian]]></dc:creator>
		<pubDate>Wed, 25 May 2011 18:48:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-136645</guid>
		<description><![CDATA[Hi folks, wow, just came across this great site.

I have a bunch of dates where i need to find the Appropriate Quarter for each date and Appropriate Year so i can create a Pivot Grid.

Any help appreciated.
Brian]]></description>
		<content:encoded><![CDATA[<p>Hi folks, wow, just came across this great site.</p>
<p>I have a bunch of dates where i need to find the Appropriate Quarter for each date and Appropriate Year so i can create a Pivot Grid.</p>
<p>Any help appreciated.<br />
Brian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Khanh</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-123706</link>
		<dc:creator><![CDATA[Khanh]]></dc:creator>
		<pubDate>Fri, 18 Mar 2011 00:05:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-123706</guid>
		<description><![CDATA[Hi,

To get the EventDate for last month I used 

SELECT * From SomeTable
Where EventDate Between DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))  AND  DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)))

Now users want only to see the EventDate between hours from 4pm to 6am of every day of last month.  Can i please have some hints?

Thanks in advance!]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>To get the EventDate for last month I used </p>
<p>SELECT * From SomeTable<br />
Where EventDate Between DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))  AND  DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)))</p>
<p>Now users want only to see the EventDate between hours from 4pm to 6am of every day of last month.  Can i please have some hints?</p>
<p>Thanks in advance!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shibu P</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-122988</link>
		<dc:creator><![CDATA[Shibu P]]></dc:creator>
		<pubDate>Sat, 12 Mar 2011 09:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-122988</guid>
		<description><![CDATA[Friends, as we start our week on a &quot;Sat&quot; and end on a &quot;Fri&quot;

SET DATEFIRST 6
SELECT GETDATE() CurrentDate,
	DATEADD(dd,(DATEPART(dw, GETDATE()) - 1) * - 1, GETDATE()) firstDayOfWeek,
	DATEADD(dd, (7 - DATEPART(dw,GETDATE())), GETDATE()) lastDayOfWeek

Regards]]></description>
		<content:encoded><![CDATA[<p>Friends, as we start our week on a &#8220;Sat&#8221; and end on a &#8220;Fri&#8221;</p>
<p>SET DATEFIRST 6<br />
SELECT GETDATE() CurrentDate,<br />
	DATEADD(dd,(DATEPART(dw, GETDATE()) &#8211; 1) * &#8211; 1, GETDATE()) firstDayOfWeek,<br />
	DATEADD(dd, (7 &#8211; DATEPART(dw,GETDATE())), GETDATE()) lastDayOfWeek</p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eden</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-111566</link>
		<dc:creator><![CDATA[Eden]]></dc:creator>
		<pubDate>Tue, 18 Jan 2011 06:30:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-111566</guid>
		<description><![CDATA[Really helpful date formats....all in one
Thanks]]></description>
		<content:encoded><![CDATA[<p>Really helpful date formats&#8230;.all in one<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-110981</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 14 Jan 2011 12:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-110981</guid>
		<description><![CDATA[select 
dateadd(month,number,dateadd(month,datediff(month,0,getdate()),0)) as first_day,
dateadd(month,number,dateadd(month,datediff(month,-1,getdate()),-1)) as last_day
from master..spt_values
where type=&#039;p&#039; and number between 0 and 11]]></description>
		<content:encoded><![CDATA[<p>select<br />
dateadd(month,number,dateadd(month,datediff(month,0,getdate()),0)) as first_day,<br />
dateadd(month,number,dateadd(month,datediff(month,-1,getdate()),-1)) as last_day<br />
from master..spt_values<br />
where type=&#8217;p&#8217; and number between 0 and 11</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siju</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-110585</link>
		<dc:creator><![CDATA[Siju]]></dc:creator>
		<pubDate>Wed, 12 Jan 2011 07:03:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-110585</guid>
		<description><![CDATA[Thanks for ur reply … This query for only one month but i want the results for 12 months for a given year.. what can i do for this…]]></description>
		<content:encoded><![CDATA[<p>Thanks for ur reply … This query for only one month but i want the results for 12 months for a given year.. what can i do for this…</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siju</title>
		<link>http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/#comment-110581</link>
		<dc:creator><![CDATA[Siju]]></dc:creator>
		<pubDate>Wed, 12 Jan 2011 05:50:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=916#comment-110581</guid>
		<description><![CDATA[Thanks for ur reply ... This query for only one month  but i want the results for 12 months for a given year.. what can i do for this...]]></description>
		<content:encoded><![CDATA[<p>Thanks for ur reply &#8230; This query for only one month  but i want the results for 12 months for a given year.. what can i do for this&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

