PowerTip: Use PowerShell to Create DateTime Object for Any Date

PowerTip: Use PowerShell to Create DateTime Object for Any Date

  • Comments 3
  • Likes

Summary: Use Windows PowerShell to easily create a DateTime object X days in the future.

Hey, Scripting Guy! Question How can I use Windows PowerShell to create a DateTime object for a date at some point in the future?

Hey, Scripting Guy! Answer Use the AddDays method from the DateTime object, for example:

(get-date).AddDays(8)

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Tis is more fun:

    [datetime]::Now + 8d


  • I wouldn't say adding a date in the future would classify as "any date"....

  • thank you