convert String to Date (without a leading zero)


hi,

i have string 7112010 (ie, 7th nov 2010), when try:

$str = "07112010"
[datetime]::parseexact($str, "dmmyyyy", $null)
works right away.

but when remove leading 'zero' string:
$str = "7112010"
[datetime]::parseexact($str, "dmmyyyy", $null)

it gives error saying: "string not recognized valid datetime."

i tried different formats, nothing working, can please?


sheesh! more ten years since y2k, , still having deal ambiguous date data, when non-ambiguous standard readily available: iso 8601 http://www.iso.org/iso/date_and_time_format.


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...