If you save them as DateTime instead of formatted strings, you can use the smaller operator ( -lt ) just like with regular numbers, and then use the format operator ( -f ) when you need to actually display the date:
$olddate = Get-Date -Date "31-dec-2013 00:00:00" $Now = Get-Date if($olddate -lt $Now){ "`$olddate is in the past!" "{0:dMyyyy}" -f $olddate "{0:dMyyyy}" -f $Now }
source share