<?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>Serge&#039;s Technology View &#187; date manipulations</title>
	<atom:link href="http://blog.dragonsoft.us/tag/date-manipulations/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dragonsoft.us</link>
	<description>Talk about Technologies, Software Architecture and Management</description>
	<lastBuildDate>Tue, 31 Jan 2012 01:43:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SQL date operations: Last 90 days, Get Date from DateTime&#8230;</title>
		<link>http://blog.dragonsoft.us/2008/05/12/sql-date-operations-last-90-days-get-date-from-datetime/</link>
		<comments>http://blog.dragonsoft.us/2008/05/12/sql-date-operations-last-90-days-get-date-from-datetime/#comments</comments>
		<pubDate>Mon, 12 May 2008 20:14:16 +0000</pubDate>
		<dc:creator>Serguei Dosyukov</dc:creator>
				<category><![CDATA[Fun stuff with SQL Server]]></category>
		<category><![CDATA[date manipulations]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql server]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=179</guid>
		<description><![CDATA[I am continuing putting some common examples of operations for Microsoft SQL Server. In addition to some of the Date related code snippets published before, there are few more today: Copyright &#169; 2012 Serge&#039;s Technology View. This Feed is for &#8230; <a href="http://blog.dragonsoft.us/2008/05/12/sql-date-operations-last-90-days-get-date-from-datetime/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am continuing putting some common examples of operations for Microsoft SQL Server.<br />
In addition to some of the Date related code snippets <a href="http://blog.dragonsoft.us/2008/02/05/first-day-last-day-of-the-month-and-sql/" target="_self">published before</a>, there are few more today:</p>
<pre class="brush: sql; title: ; notranslate">-- Last 90 days:
select DATEADD(day, -90, GETDATE())
-- Get Date portion of DateTime value
select DATEADD(d, 0, DATEDIFF(d, 0, getdate()))
</pre>
<hr/><span style="font-size: 7pt">Copyright &copy; 2012 <strong><a href="http://blog.dragonsoft.us">Serge&#039;s Technology View</a></strong>. This Feed is for personal non-commercial use only.</span>]]></content:encoded>
			<wfw:commentRss>http://blog.dragonsoft.us/2008/05/12/sql-date-operations-last-90-days-get-date-from-datetime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL date operations: First day, Last day of the month&#8230;</title>
		<link>http://blog.dragonsoft.us/2008/02/05/first-day-last-day-of-the-month-and-sql/</link>
		<comments>http://blog.dragonsoft.us/2008/02/05/first-day-last-day-of-the-month-and-sql/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 16:56:14 +0000</pubDate>
		<dc:creator>Serguei Dosyukov</dc:creator>
				<category><![CDATA[Fun stuff with SQL Server]]></category>
		<category><![CDATA[date manipulations]]></category>
		<category><![CDATA[piclens]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql server]]></category>
		<guid isPermaLink="false">http://blog.dragonsoftru.com/2007/01/18/first-day-last-day-of-the-month-and-sql/</guid>
		<description><![CDATA[Did you ever faced a situation when you need quickly calculate some boundaries of the Date value like First Day of the month, Last Day of the month, etc&#8230; in T-SQL? Colegue of mine asked me this question&#8230; WOW! What do &#8230; <a href="http://blog.dragonsoft.us/2008/02/05/first-day-last-day-of-the-month-and-sql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Did you ever faced a situation when you need quickly calculate some boundaries of the Date value like First Day of the month, Last Day of the month, etc&#8230; in T-SQL?</p>
<p>Colegue of mine asked me this question&#8230; WOW! What do you know&#8230;<br />
It is actually very easy if we think about it for a second&#8230;</p>
<p>So lets fun begin&#8230;</p>
<pre class="brush: sql; title: ; notranslate">--First Day of the Current Month:
select DATEADD(mm, DATEDIFF(mm, 0, GETDATE()), 0)
-- Last Day of the Current Month:
select DATEADD(ms, -3, DATEADD(mm, DATEDIFF(m, 0, GETDATE()) + 1, 0))
-- Last Day of Prior Month:
select DATEADD(ms, -3, DATEADD(mm, DATEDIFF(mm, 0, GETDATE()), 0))
-- First Day of the Current Year:
select DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)
-- Last Day of the Current Year:
select DATEADD(ms, -3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0))
-- Last Day of Prior Year:
select DATEADD(ms, -3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))
</pre>
<p>And some more&#8230;</p>
<pre class="brush: sql; title: ; notranslate">-- First Day of the Quarter:
select DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0)
-- Monday of the Current Week:
select DATEADD(wk, DATEDIFF(wk, 0, GETDATE()), 0)
-- Midnight for the Current Day:
select DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)
-- First Monday of the Month:
select DATEADD(wk, DATEDIFF(wk, 0, DATEADD(dd, 6 - DATEPART(day, GETDATE()), GETDATE())), 0)
-- Last 2 full months
select DATEADD(ms, -3, DATEADD(mm, DATEDIFF(mm, 0, GETDATE()) - 2, 0))
</pre>
<hr/><span style="font-size: 7pt">Copyright &copy; 2012 <strong><a href="http://blog.dragonsoft.us">Serge&#039;s Technology View</a></strong>. This Feed is for personal non-commercial use only.</span>]]></content:encoded>
			<wfw:commentRss>http://blog.dragonsoft.us/2008/02/05/first-day-last-day-of-the-month-and-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

