The VBScript Network and Systems Administrator's Cafe:

SQL Server

Feb 10 2009   6:11PM GMT

Easily compare dates from with in VBScript



Posted by: Jerry Lees
VBScipt, DATEDIFF, date, Dates, Date Comparison, VBScript Functions

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.

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 the datediff function!

Below is an example that returns the number of seconds, minutes, hours, days, and years between now and February 25, 1973.

Option Explicit

Dim DateThen, DateNow

DateThen = “2/25/1973″
DateNow = Now

WScript.Echo DateDiff(”s”,DateThen, DateNow)
WScript.Echo DateDiff(”n”,DateThen, DateNow)
WScript.Echo DateDiff(”h”,DateThen, DateNow)
WScript.Echo DateDiff(”d”,DateThen, DateNow)
WScript.Echo DateDiff(”yyyy”,DateThen, DateNow)

Enjoy!

Dec 23 2008   3:12AM GMT

A useful site that contains a Microsoft SQL version information database



Posted by: Jerry Lees
SQL Server, Server Patching, Essential sites, web tools, Microsoft SQL Server

I don’t get the occasion to manage SQL servers in a DBA role any longer, like MrDenny in his blog, nor have I been a true assigned DBA– I’ve only worked at places where the database servers were treated like any other server. Basically, mine to manage. Those of you in small to medium enterprises know what I’m talking about… If it plugs into the network it’s a Network/Server admin’s responsibility.

Now my role is more along the lines of Supporting the web applications that use the services that the database servers provide. Leaving the DBA role up to the folks assigned the title of DBA. Oh, how I used to think that would be so much easier! But that was when I imagined a team of folks who thought and worked like I did… Instead on occasion you get the folks on the other team who don’t believe a problem exists.

Well, I’ve recently found a site that really comes in handy in determining if SQL patches have been applied or if they may be relevant to an article you are reading that looks promising over at SQLSecurity.com that  is a database of SQL Server patches that helps you determine if a patch is relevant to your installation or not.

Hopefully, this will help you out in your challenges!