DEV Community

taijidude
taijidude

Posted on

1

Date Basics

Short post before Christmas:

Calling Get-Date gives you a DateTime Object to work with:

(Get-Date).GetType()
Enter fullscreen mode Exit fullscreen mode

Alt Text

It is also possible to call Get-Date with a specific date string.

Get-Date "01.01.1970"
Enter fullscreen mode Exit fullscreen mode

To get a Date later than my specified date use the methods starting with Add.

Alt Text

To get the Date a week from today simple type the following:

(Get-Date).addDays(7).toString("dd.MM.yyyy")
Enter fullscreen mode Exit fullscreen mode

Alt Text

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")
Enter fullscreen mode Exit fullscreen mode

Alt Text

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
Enter fullscreen mode Exit fullscreen mode

Alt Text

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more