Time Delta
Simon Taylor
simon at unisolve.com.au
Thu Oct 2 02:51:36 CDT 2003
Hello Scott,
> * Here is DateTime 1
> * Here is DateTime 2
> * Here is the working week (Mon-Fri, 9-5) (or whatever we define)
> * Tell me the working hours between DateTime 1 and DateTime 2
>
> eg:
> DateTime 1 DateTime 2 Difference
>
> 19/8/2003 16:35 20/8/2003 11:15 2:40
>
> or - 2 hours, 40 minutes
>
> What is the simplest, shortest way.
I'd use Date::Manip as follows:
#!/usr/bin/perl -w
use strict;
use Date::Manip;
my $err;
my $date;
$date = DateCalc("August 19,2003 16:35", "August 20, 2003 11:15", \$err, 3);
print "delta: $date\n";
Which gives the output:
delta: +0:0:0:0:3:40:0
ie: 3 hrs and 40 minutes.
You'll have to tell date::Manip what constitutes business hours in the region
you're working in, and also what the default date format is so that it will
understand DD/MM/YYYY date formats.
Regards,
Simon Taylor
--
Unisolve Pty Ltd - Melbourne, Australia
+61 3 9568 2005
More information about the Melbourne-pm
mailing list