Link to home
Start Free TrialLog in
Avatar of mikeydk
mikeydkFlag for Denmark

asked on

Compare dates

Hey

How do I: (compare)

If ("01-01-2018 18:32:51" -gt "01-12-2017") { write-host "Hello World"}

(24H)

Mike

Powershell
Avatar of Norie
Norie

Mike

Not 100% sure what you are after but try this, it will convert the 'text' date/time values you have into real date/time values and compare them.
If ([datetime]"01-01-2018 18:32:51" -gt [datetime]"01-12-2017") { write-host "Hello World"} 

Open in new window

Avatar of mikeydk

ASKER

Hey

Great - but how do I type cast the string - when using european format? (dd-MM-yyyy)
SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial