Forum Discussion

tehatchKFI's avatar
tehatchKFI
Copper Contributor
Sep 28, 2023

Get-date AddDays Method Not Returning a Value

I have an unusual one. The AddDays method of Get-Date isn't returning a value on my computer. It's not working in PowerShell 5 or 7. Get-date by itself works find and returns today's date.     PS...
  • LainRobertson's avatar
    Sep 28, 2023

    tehatchKFI 

     

    In line six of your original post, you have made a small syntax mistake, which is why it returns nothing.

     

    From line 6, this:

     

    (get-date).AddDays.(-30)

     

    Should have been this (note the removal of the period prior to the "(-30)"):

     

    (get-date).AddDays(-30)

     

    Cheers,

    Lain

Resources