Short post before Christmas:
Calling Get-Date gives you a DateTime Object to work with:
(Get-Date).GetType()
It is also possible to call Get-Date with a specific date string.
Get-Date "01.01.1970"
To get a Date later than my specified date use the methods starting with Add.
To get the Date a week from today simple type the following:
(Get-Date).addDays(7).toString("dd.MM.yyyy")
To get the Date a week prior from today i need to use the addDays() method with a parameter of -7.
(Get-Date).addDays(-7).toString("dd.MM.yyyy")
How the date is printed into the shell you can control with the parameter value for the toString() Methode as seen in the two examples above.
If you want to check which day of the week the DateTime Object is set to, you can use the DayOfWeek Member.
(Get-Date).DayOfWeek
Top comments (0)