Calculating Time Differences

by Nov 13, 2009

Use New-Timespan and submit a date if you’d like to know how long it is until next Christmas. New-Timespan automatically compares this date to the current date (and time) and returns the timespan in a number of different formats from which you can choose. For example, to get the timespan in days, use this:

(New-Timespan 12/24/2009).Days

Note that dates that are in the future return negative timespans – unless you bind your date as -end parameter instead of -start:

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

Twitter This Tip! ReTweet this Tip!