Ying Li at myITforum.com

PowerShell & System Center

How Many Days Till New Year

If someone ever asks you,” How long is it till new year (or any day for that matter)?” Below is a little PowerShell date math routine I borrowed from Jeffrey Snover, the architect of PowerShell.

Function TillNewYear

{
 $Now = [DateTime]::Now
 [Datetime]([string] ($now.Year + 1) + "-01-01") - $Now
}

TillNewYear

Posted: Apr 16 2007, 09:52 AM by yli628 | with 1 comment(s)
Filed under:

Comments

rodtrent said:

Love it!

# April 16, 2007 10:59 AM