How do I get the last day of the month with PowerShell?

green

Here’s how to programmatically get the last day of last month in PowerShell:

 

To get the last day of this month, this will work:

 green

3 Comments How do I get the last day of the month with PowerShell?

    1. Kamal

      Sure – if it’s just to display (and not for date-based calculations) just append something like:

      .tostring(“dd-MM-yyyy”)

      Or:

      .tostring(“yyyyMMdd”)

      You can format that pretty much anyway you want it to look.

      Reply
  1. Pallav Kumar

    Thanks for the post Kamal. I want to get the week day of last day of month. So for example for 30 Sep 2018, I want the value Sunday.

    Thanking in advance.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *