<?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 – how to get date differences</title>
	<atom:link href="http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/feed/" rel="self" type="application/rss+xml" />
	<link>http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/</link>
	<description>Ramblings and musings of a Dynamics GP MVP</description>
	<lastBuildDate>Sat, 19 May 2012 09:34:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Victoria Yudin</title>
		<link>http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/#comment-5244</link>
		<dc:creator><![CDATA[Victoria Yudin]]></dc:creator>
		<pubDate>Mon, 13 Sep 2010 13:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://victoriayudin.wordpress.com/?p=483#comment-5244</guid>
		<description><![CDATA[&lt;strong&gt;Coding specific dates in SQL Server...&lt;/strong&gt;

Quite often when writing reports I need to write a formula to calculate dates. Dates are not very straightforward...]]></description>
		<content:encoded><![CDATA[<p><strong>Coding specific dates in SQL Server&#8230;</strong></p>
<p>Quite often when writing reports I need to write a formula to calculate dates. Dates are not very straightforward&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Coding specific dates in SQL Server &#171; Victoria Yudin</title>
		<link>http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/#comment-5243</link>
		<dc:creator><![CDATA[Coding specific dates in SQL Server &#171; Victoria Yudin]]></dc:creator>
		<pubDate>Mon, 13 Sep 2010 12:58:48 +0000</pubDate>
		<guid isPermaLink="false">http://victoriayudin.wordpress.com/?p=483#comment-5243</guid>
		<description><![CDATA[[...] so that I do not have to re-write the code every time. I have previously posted some code on calculating date differences in SQL, however below is some code for getting specific [...]]]></description>
		<content:encoded><![CDATA[<p>[...] so that I do not have to re-write the code every time. I have previously posted some code on calculating date differences in SQL, however below is some code for getting specific [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victoria Yudin</title>
		<link>http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/#comment-2721</link>
		<dc:creator><![CDATA[Victoria Yudin]]></dc:creator>
		<pubDate>Tue, 08 Dec 2009 14:57:37 +0000</pubDate>
		<guid isPermaLink="false">http://victoriayudin.wordpress.com/?p=483#comment-2721</guid>
		<description><![CDATA[Sandy, 

This will get you everyone with a Start Date after today minus one year:
&lt;code&gt;select * from UPR00100
where STRTDATE &gt; DATEADD(yy,-1,GETDATE())&lt;/code&gt;

If you want to exclude future start dates, you could add 
&lt;code&gt;and STRTDATE &lt;= GETDATE()&lt;/code&gt;

&lt;em&gt;-Victoria&lt;/em&gt;]]></description>
		<content:encoded><![CDATA[<p>Sandy, </p>
<p>This will get you everyone with a Start Date after today minus one year:<br />
<code>select * from UPR00100<br />
where STRTDATE &gt; DATEADD(yy,-1,GETDATE())</code></p>
<p>If you want to exclude future start dates, you could add<br />
<code>and STRTDATE &lt;= GETDATE()</code></p>
<p><em>-Victoria</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandy Wyman</title>
		<link>http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/#comment-2720</link>
		<dc:creator><![CDATA[Sandy Wyman]]></dc:creator>
		<pubDate>Tue, 08 Dec 2009 14:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://victoriayudin.wordpress.com/?p=483#comment-2720</guid>
		<description><![CDATA[Victoria, I&#039;m trying to figure out how I could get employees that were hired in the last 12 months.  I would use the computer date and the StartDate from Payroll Master table, but can&#039;t seem to put the syntax together correctly.
Thanks,
Sandy]]></description>
		<content:encoded><![CDATA[<p>Victoria, I&#8217;m trying to figure out how I could get employees that were hired in the last 12 months.  I would use the computer date and the StartDate from Payroll Master table, but can&#8217;t seem to put the syntax together correctly.<br />
Thanks,<br />
Sandy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Victoria Yudin</title>
		<link>http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/#comment-830</link>
		<dc:creator><![CDATA[Victoria Yudin]]></dc:creator>
		<pubDate>Fri, 06 Mar 2009 19:03:24 +0000</pubDate>
		<guid isPermaLink="false">http://victoriayudin.wordpress.com/?p=483#comment-830</guid>
		<description><![CDATA[Justin,

You could use something like this:
&lt;code&gt;select * from YourTable
where (select cast(datediff(d, LastLogin, getdate()) 
AS DECIMAL (8,1))/365) &lt;= 2&lt;/code&gt;

That should give you every row from YourTable with a LastLogin in the last 2 years.

&lt;em&gt;-Victoria&lt;/em&gt;]]></description>
		<content:encoded><![CDATA[<p>Justin,</p>
<p>You could use something like this:<br />
<code>select * from YourTable<br />
where (select cast(datediff(d, LastLogin, getdate())<br />
AS DECIMAL (8,1))/365) &lt;= 2</code></p>
<p>That should give you every row from YourTable with a LastLogin in the last 2 years.</p>
<p><em>-Victoria</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Meese</title>
		<link>http://victoriayudin.com/2008/10/27/sql-server-how-to-get-date-differences/#comment-829</link>
		<dc:creator><![CDATA[Justin Meese]]></dc:creator>
		<pubDate>Fri, 06 Mar 2009 17:27:26 +0000</pubDate>
		<guid isPermaLink="false">http://victoriayudin.wordpress.com/?p=483#comment-829</guid>
		<description><![CDATA[How would I go about selecting records from a table where their last login date was greater than today&#039;s date less 2 years?  That way I only get users that have logged in within the last two years...

thanks for your help if you can.]]></description>
		<content:encoded><![CDATA[<p>How would I go about selecting records from a table where their last login date was greater than today&#8217;s date less 2 years?  That way I only get users that have logged in within the last two years&#8230;</p>
<p>thanks for your help if you can.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

