Using Relative Dates

by Jan 5, 2010

Sometimes, you need relative dates. What date was 14 days ago? Maybe you want to use this relative date to select files of a certain age. You can use Get-Date in conjunction with New-Timespan to construct relative dates. The following line will get you the date 14 days ago:

(Get-Date) (New-Timespan -day 14)

Twitter This Tip! ReTweet this Tip!