W2KSG: Date differences

The number of days between two dates has been covered before so we’ll keep this one quick.

Script Center Home > Microsoft Windows 2000 Scripting Guide > Scripting Concepts and Technologies for System Administration > VBScript Primer > VBScript Reference > Working with Dates and Times  Date Arithmetic

Listing 2.16

$test = [datetime]"10/10/2008"
$span = $test – $(Get-Date)
"Days until 10 October = $($span.days)"

Create a test date and then subtract today’s date from it to create a timespan object. Display the number of days.  Check out the other properties of timespan with get-member


Share this post :


Technorati Tags:

About these ads
This entry was posted in Powershell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s