Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a month number to month name using PowerShell

Tags:

I need to convert "08" to display "August"

I can't use Get-Date as this is coming from a fileName which may or may not change.

So currently I split the name into an array, access the data I need, and need to convert the mm section to MMMM

01 = January 03 = March etc 
like image 362
Paul L Avatar asked Aug 05 '14 00:08

Paul L


People also ask

How do you calculate month names from months?

Please do as follows: Select a blank cell next to the sales table, type the formula =TEXT(A2*29,"mmm") (Note: A2 is the first number of the Month list you will convert to month name), and then drag the AutoFill Handle down to other cells. Now you will see the numbers (from 1 to 12) are converted to normal month names.

How do I get current month in PowerShell?

The Get-Date cmdlet is a lightweight command used in PowerShell. This command returns a DateTime object that displays the current date or a custom date.

How do I echo in PowerShell?

Type “Write-Output” in the scripting pane of the “PowerShell ISE“, and then write hyphen (-). A dropdown menu will be activated, which contains the supported parameter: For instance, the echo/Write-Output command prints the output as an individual expression.


1 Answers

Full month name:

(Get-Culture).DateTimeFormat.GetMonthName(8) 

Abbreviated:

(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName(8) 
like image 146
Rohn Edwards Avatar answered Oct 09 '22 19:10

Rohn Edwards