Learn about Windows PowerShell
Summary: Use New-TimeSpan to produce the time difference between two dates.
I know I can subtract dates, but is there a Windows PoweShell cmdlet to show me the time difference between dates?
Use New-TimeSpan and supply the information! For example, to show the difference between today and the upcoming New Year:
NEW-TIMESPAN –Start $StartDate –End $EndDate
Very much required for all the administrators!!!
Why not just subtract the dates and let PowerShell do the conversion for you? The results are the same just a little less explicit.
PS >($EndDate - $StartDate).gettype().Name
You are correct. There are two ways in PowerShell to do the same exact thing. Neither is wrong. One uses a Cmdlet and one uses Math (Although I suspect the Cmdlet is just coughing in the math). Choose whichever makes more sense for you to do :)
$StartDate is not needed here: PS will use current date for either of two parameters, if it's not explicitly specified. So New-TimeSpan -End 1-Jan-2014 would probably do. ;)
Please use day-numbers above 12 in examples, to prevent confusion between day and month position.