Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You can use Time::Piece to perform the date comparisons. Then it's just a matter of choosing a sensible initial value to compare against. You could use whatever is first in your array but I've chosen to use the epoch here:

use strict; use warnings; use Test::More tests => 1; use Time::Piece; my @aoh = ( { 'Name' => 'First Segment', 'Balance' => '183.57', 'days' => 0, 'First Date' => '12/02/2020', 'payment' => 0, 'Activity Date' => '07/05/2020', 'Total Commission' => 0, }, { 'Name' => 'Discontinue Segment', 'Balance' => '67.14', 'days' => 3, 'First Date' => '17/02/2020', 'payment' => 0, 'Activity Date' => '27/03/2020', 'Total Commission' => 0.12, }, { 'Name' => 'Last Segment', 'Balance' => '12.56', 'days' => 7, 'First Date' => '19/03/2020', 'payment' => 0, 'Activity Date' => '21/04/2020', 'Total Commission' => 0, } ); my $maxdate = localtime (0); for my $hr (@aoh) { my $date = Time::Piece->strptime ($hr->{'Activity Date'}, '%d/%m/% +Y'); $maxdate = $date if $date > $maxdate; } is $maxdate->dmy ('/'), '07/05/2020';

In reply to Re: Find maximum (Activity) date from array hash. by hippo
in thread Find maximum (Activity) date from array hash. by Sami_R

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-25 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found