title: Powershell timestamp format changes in Excel
body: <p>I'm building a function which returns the date of the last 6 months, lets you choose one, and appends it to the column <strong>Date</strong> in the MMM/YY format. I'm using this in a GUI and it shows it like this:</p>
  
  <p><a href="https://i.stack.imgur.com/KClrl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KClrl.png" alt="enter image description here"></a></p>
  
  <p>Somehow it only works for the month october.. What's going wrong here??</p>
  
  <p><a href="https://i.stack.imgur.com/qDBhm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qDBhm.png" alt="enter image description here"></a></p>
  
  <p>Code I'm using:</p>
  
  <pre><code>$dateList=-6..0 |ForEach-Object{ (Get-Date).AddMonths($_).ToString('MMM/yy') }
  $txtDateList.Items.Clear()
  foreach ($textdate in $dateList) {
                        $txtDateList.Items.Add($textdate)
                        }
  
  $txtDate = $txtDateList.SelectedItem
  $sheet.cells.item($row, $colDate.Column).value = $txtDate```
  </code></pre>