Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Find Number of Hours in Number of Days

$
0
0

Summary: Use Windows PowerShell to find the number of hours in a number of days.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily figure out how many hours are in 30 days without
           doing any multiplication?

Hey, Scripting Guy! Answer Use New-TimeSpan to create a timespan object for 30 days. The output will tell the number of hours,
           minutes, and seconds in the timespan. Here is an example:

New-TimeSpan -Days 30

To return only the number of hours, retrieve the TotalHours property:

PS C:\> (New-TimeSpan -Days 30).totalhours

720


Viewing all articles
Browse latest Browse all 3333

Trending Articles