PowerTip: Use PowerShell to Subtract Timespans

Doctor Scripto

Summary: Subtract timespans by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to subtract 2 days and 14 hours from 12 days and 1 hour to determine the amount of time left on a project?

Hey, Scripting Guy! Answer Create two timespans using the New-Timespan cmdlet, and then subtract them from each other:

(New-TimeSpan -Days 12 -Hours 1) – (New-TimeSpan -Days 2 -Hours 14)

0 comments

Discussion is closed.

Feedback usabilla icon