ParseExact is told the format of the date it is expected to parse, not the format you wish to get out.
$invoice="01-Jul-16"
[datetime]::parseexact($invoice, 'dd-MMM-yy', $null)
If you then wish to output a date string:
[datetime]::parseexact($invoice, 'dd-MMM-yy', $null).ToString('yyyy-MM-dd')
More Related Contents:
- PowerShell says “execution of scripts is disabled on this system.”
- Create objects with custom properties containing derived filesystem path information and export them to a CSV – calculated properties
- What’s the best way to determine the location of the current PowerShell script?
- Using a Variable (PowerShell) inside of a command
- Changing PowerShell’s default output encoding to UTF-8
- PowerShell outputting array items when interpolating within double quotes
- PSCustomObject to Hashtable
- How can I make PowerShell handle [ or ] in file name well?
- Get remote registry value
- What’s the difference between single quote and double quote to define a string in powershell
- Catching FULL exception message
- Powershell call msbuild with nested quotation marks
- Redirection of standard and error output appending to the same log file
- Replacing only the first occurrence of a word in a string
- How can I get the file system location of a PowerShell script?
- How to use the curl command in PowerShell?
- Ignoring an errorlevel != 0 in Windows PowerShell (ISE)
- DateTime subtraction not working in PowerShell – assignment vs. equality operator
- Loading Assemblies from NuGet Packages
- Issue with Powershell update string in each file within a folder
- How can I run a PowerShell script with white spaces in the path from the command line?
- How can I start Powershell script as noprofile in Visual Studio Code
- Output file doesn’t match Write-Host
- Running CMD command in PowerShell
- How to execute a PowerShell function several times in parallel?
- Using Powershell environmental variables as strings when outputting files
- PowerShell launch script in new instance
- Create Outlook email draft using PowerShell
- Remove last line from file with Powershell
- How to return specific data type from PowerShell function i.e. DataTable