In this PowerShell Code-Golf tip, you can use scientific notation to easily generate numbers with a power of 10: https://codegolf.stackexchange.com/a/193/6776
i.e. 1e7
prints the number 10,000,000
.
If I pass this get-date
value (or the date
alias, for code golf purposes), I get one second: i.e. date 10000000
=> 01 January 0001 00:00:01
.
But if I use scientific notation, even with parentheses (i.e. date (1e7)
), I get an error message:
Get-Date : Cannot bind parameter 'Date'. Cannot convert value "10000000" to type "System.DateTime". Error: "String was not recognized as a valid DateTime." At line:1 char:6 + date (1e7) + ~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-Date], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetDateCommand
Question
Is there a way to use scientific notation with the default parameter (date) of Get-Date?
source share