Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Calculate difference between multiple days

by Anonymous Monk
on Oct 25, 2018 at 09:59 UTC ( [id://1224650]=note: print w/replies, xml ) Need Help??


in reply to Re: Calculate difference between multiple days
in thread Calculate difference between multiple days

Hello all and thank you for your kind replies!
I actually meant an all-against-all comparison, but I think I will go for something like this:
#!/usr/bin/env perl use strict; use warnings; my $date_first = '2005-09-27'; my $date_second = '2019-12-22'; my $date_third = '1999-12-22'; use Time::Piece; my $date1 = localtime( $date_first ); my $date2 = localtime( $date_second ); my $date3 = localtime( $date_third ); if( $date2 > $date1 and $date2 > $date3 and $date1 > $date3) { print "correct\n"; }

since I just needed to only compare between them and not calculate days. This works for me now, thanks again!

Replies are listed 'Best First'.
Re^3: Calculate difference between multiple days
by hippo (Bishop) on Oct 25, 2018 at 10:10 UTC
    if( $date2 > $date1 and $date2 > $date3 and $date1 > $date3)

    Can you spot which of these three comparisons is redundant?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1224650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-23 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found