PowerTip: Get Week of Year with PowerShell

Summary: Learn how to use Windows PowerShell to get the week of the year.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find how many weeks are left in the current year—without doing lot of math or
           calendaring stuff?

Hey, Scripting Guy! Answer Use the Get-Date cmdlet but specify a –uformat of %V:

Get-Date -UFormat %V

Note  Please remember that UFormat strings are case sensitive, so it is capital V, not lowercase v.

Comments (5)

  1. Aman Bansal says:

    The output seems to be different. I get 39 after running the command

  2. Brad_Voris says:

    It gives you what the current month is in number of weeks. If you want how many weeks are left in the year it is just a formula:
    $a = get-date -UFormat %V
    $b = 52 – $a
    write-host $b

  3. Dhandapani says:

    It shows which week you are in ( in 01-53 week format). its cool…..

  4. Sander says:

    Could someone explane the workings behind %V ?
    What does %V stand for, or does ?

  5. Alfredo de las Vegas says:

    This only works if Jan 1st is Monday.
    Get-Date "2016-01-06" -UFormat "%V"

    and should be 2

Skip to main content