PowerTip: Displaying Only the Current Year in PowerShell

Summary: Learn how to display only the current year.

Hey, Scripting Guy! QuestionHow can I use Windows PowerShell to display only the current year?

Hey, Scripting Guy! Answer

  1. get-date -Format yyyy

  2. get-date –format yy

  3. get-date –f yyyy

  4. (Get-Date).year

  5. Get-Date -UFormat %Y

  6. Get-Date -UFormat %

Comments (9)

  1. jrv says:

    @Walid – good explanation and your english is fine.

    I learned somthing here today.  Thank you Walid and Ed.

    What you have pointed out is this:

    PS>function get-year{date -uf %Y}



  2. Anonymous says:

    And remember that these might give a different result to


  3. K_Schulte says:

    @jrv: Magic Ed Wilson @ work …

    The wizard of South Carolina 🙂

    As Teresa told me, "Date and time voodoo" is one of his hobbies

    besides diving, wood working and (underwater) photography


  4. mredwilson says:

    @JRV hehehe

    @K_Schulte thanks …

    @Walid Toumi these are great … thanks for sharing.

    @JRV cool. Thanks.

    @JRV @Walid Toumi can you explain WHY Date works? It is not a cmdlets, nor it is a function or an alias!

  5. jrv says:

    "Double, double toil and trouble; Fire burn, and caldron bubble"

    It's witchcraft…

    More magic from everybodies favorite mad scientist.

  6. jrv says:

    @Walid – I'll see you and raise you one:


  7. Walid Toumi says:


    for fun:

    PS> ( date ).ToString('yyyy')

    PS> [datetime]::Today.Year

    PS> (Get-WmiObject Win32_LocalTime).Year


  8. Walid Toumi says:


    all cmdlet with verb "get" works




    only get-process and get-command don't work

    because proccess is a special keyword "help keyword"

    and command is old shell win command.com

    sorry for my english

  9. Ed Wilson says:

    @all one of the great things about PowerShell is that is simplifies working with dates. In other languages I have used, datetime manipulation was always a major pain. I still remember old databases that had one column for month, another column for day, and another column for year. UGH!!!

Skip to main content