1

I have an array with Tick formatted dates I'd like to get the highest number from:

$date
637486420264667458
637486420339152660

Using Measure-output -Maximum I get the number but not in the same usable format:

$date | measure -Maximum

Count    : 2
Average  :
Sum      :
Maximum  : 6.37486420339153E+17
Minimum  :
Property :

Is there a way to output 637486420339152660 instead of 6.37486420339153E+17

TyMac
  • 783
  • 2
  • 9
  • 32
  • In short: Unfortunately, as of PowerShell 7.1, [`Measure-Object`](https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/measure-object) invariably uses `[double]` results for its `-Sum`, `-Maximum`, `-Minimum`, `-Average` and `-StandardDeviation` operations - see [this answer](https://stackoverflow.com/a/60609025/45375) to the linked duplicate for background information and for workarounds via the static methods of [`[System.Linq.Enumerable]`](https://learn.microsoft.com/en-US/dotnet/api/System.Linq.Enumerable) – mklement0 Feb 11 '21 at 17:58
  • 1
    This worked: [Linq.Enumerable]::Max([long[]] $date) – TyMac Feb 11 '21 at 18:11
  • Yes, my bad: given the variable name's name, `$date`, I had assumed that it contains an array of `[datetime]` values, in which case you need the `.Ticks` part; but I see that it's probably `[long]`s, in which case `[Linq.Enumerable]::Max([long[]] $date)` is indeed the right solution. – mklement0 Feb 11 '21 at 18:14

0 Answers0