header image

W2KSG: Date differences

Posted by: | August 28, 2008 | No Comment |

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




Technorati Tags:

under: PowerShell original