Learning your way around., Powershell

Formatting dates from text or objects

Ever imported data just to have a non readable date stamp?

Get-date can take your text that is a date and turn it into something more readable.

Take “15-FEB-20” for example. It’s not really a wildly used format.

Pipe that to get-date like so:

Then you can format your date to remove time and what not.

If you have imported the data you can fix the entry using the select statement.

$data |select name,@{name=’Birthday’;e={$_.birthday | get-date -format MM-dd-yyyy}}

1 thought on “Formatting dates from text or objects”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.