 




<?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>The VBScript Network and Systems Administrator&#039;s Cafe &#187; Dates</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/tag/dates/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator</link>
	<description></description>
	<lastBuildDate>Tue, 11 Oct 2011 18:36:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Easily compare dates from with in VBScript</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easily-compare-dates-from-with-in-vbscript/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easily-compare-dates-from-with-in-vbscript/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 18:11:43 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[date]]></category>
		<category><![CDATA[Date Comparison]]></category>
		<category><![CDATA[DATEDIFF]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[VBScipt]]></category>
		<category><![CDATA[VBScript Functions]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easily-compare-dates-from-with-in-vbscript/</guid>
		<description><![CDATA[On occasion you need to compare two dates in your scripts, this can be a real challenge when you approach the date as if it were a string and/or compare the date parts to one another. Then finding the difference can be a whole other set of challenges if your dates span several months, days, [...]]]></description>
				<content:encoded><![CDATA[<p>On occasion you need to compare two dates in your scripts, this can be a real challenge when you approach the date as if it were a string and/or compare the date parts to one another. Then finding the difference can be a whole other set of challenges if your dates span several months, days, or years.</p>
<p>Luckily, there is a function right into VBScript that helps you compare two dates to one another and returns the difference in a unit of time that you specify! That function is <a href="http://www.w3schools.com/vbScript/func_datediff.asp" target="_blank">the datediff function</a>!</p>
<p>Below is an example that returns the number of seconds, minutes, hours, days, and years between now and February 25, 1973.</p>
<p><span style="color: #0000ff">Option Explicit</span></p>
<p><span style="color: #0000ff">Dim DateThen, DateNow</span></p>
<p><span style="color: #0000ff">DateThen = &#8220;2/25/1973&#8243;<br />
DateNow = Now</span></p>
<p><span style="color: #0000ff">WScript.Echo DateDiff(&#8220;s&#8221;,DateThen, DateNow)<br />
WScript.Echo DateDiff(&#8220;n&#8221;,DateThen, DateNow)<br />
WScript.Echo DateDiff(&#8220;h&#8221;,DateThen, DateNow)<br />
WScript.Echo DateDiff(&#8220;d&#8221;,DateThen, DateNow)<br />
WScript.Echo DateDiff(&#8220;yyyy&#8221;,DateThen, DateNow)<br />
</span></p>
<p>Enjoy!</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/easily-compare-dates-from-with-in-vbscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
