Powered By Blogger

Aug 1, 2012


Calculating Time Differences


This post is about calculating time difference using PowerShell. 

We can use 'New-Timespan' for calculating the difference between the current date and a specific date. New-Timespan automatically compares the inserted date to the current date and returns the timespan in number of different formats from which you can choose. 

For an example if we want to get the difference in days we can use (New-Timespan 12/24/2012).Days


Note that if you insert a date in the future you will the get the output as a negative value. To get rid of the negative effect we can use '-end' parameter after the New-Timespan.

(New-Timespan -end 12/24/2012).Days






No comments:

Post a Comment