- <#
- .SYNOPSIS
- Displys number of days in a particular month.
- .DESCRIPTION
- This scrips uses System.DateTime to determine, then
- display, the numbe of days in some months.
- .NOTES
- File Name : Get-DaysInMonth.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- PSH [C:\foo]: . 'C:\foo\Get-daysinmonth.ps1'
- There are 31 days in July 2001
- There are 28 days in February 1998
- There are 29 days in February 1996
- There are 31 days in August 1950
- #>
- ##
- # Start of script
- ##
- # Create variables representing months
- $July = 7
- $February = 2
- $August = 8
- # daysInJuly should be 31.
- $daysInJuly = [System.DateTime]::DaysInMonth(2001, $July)
- "There are $daysinjuly days in July 2001"
- # DaysInFeb should be 28 because the year 1998 was not a leap year.
- $daysInFeb = [System.DateTime]::DaysInMonth(1998, $February)
- "There are $daysinfeb days in February 1998"
- # daysInFebLeap gets 29 because the year 1996 was a leap year.
- $daysInFebLeap = [System.DateTime]::DaysInMonth(1996, $February)
- "There are $daysinfebleap days in February 1996"
- # An august year indeed.
- $daysInAugust = [System.DateTime]::DaysInMonth(1950, $August)
- "There are $daysinAugust days in August 1950"
- # End of Script
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Thursday 12 March 2009
Get-DaysInMonth.ps1
Labels:
DaysInMonth,
powershell,
PowerShell scripts,
system.datetime
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment