snehit.ar has asked for the wisdom of the Perl Monks concerning the following question:
Error :Argument "2:00:00" isn't numeric in numeric gt (>) at test.pl line 37. Argument "-6:-8:15" isn't numeric in numeric gt (>) at test.pl line 37. -6:-8:15#!/usr/bin/perl use warnings; use strict; use DateTime; use DateTime::Duration; # my $file = 'C:/Users/snehit.rahate/Perl/events.xml'; # #my $xpath = q{//custom_attribute_list/custom_attribute[normalize-sp +ace(name)='SLB_SSRID']/value}; # my $xp = XML::XPath->new(filename=>$file); # my $nodeset = $xp->find("//custom_attribute_list/custom_attribute[no +rmalize-space(name)='SLB_SSRID']/value"); # for my $node ($nodeset->get_nodelist) { # print " XML::XPath: ",$node->string_value,"\n"; # } use DateTime::Format::Duration; my $dtnow = DateTime->now; $dtnow =~ s/T/ /; $dtnow =~ m/(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/gi; my $now_hour = $4; my $now_minute = $5; my $now_second = $6; my $dtevent = '2017-06-15 13:14:31'; $dtevent =~ m/(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/gi; my $event_hour = $4; my $event_minute = $5; my $event_second = $6; my $diffhour = $now_hour - $event_hour; my $diffminute = $now_minute - $event_minute; my $diffsecond = $now_second - $event_second; my $event_time = $diffhour.":".$diffminute.":".$diffsecond; print $event_time; if ($event_time > "2:00:00") { print "Start the service if time is more then 2 hours"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: execute if date is greater then 2hours
by haukex (Archbishop) on Jun 28, 2017 at 08:01 UTC | |
by snehit.ar (Beadle) on Jun 28, 2017 at 10:41 UTC | |
|
Re: execute if date is greater then 2hours
by 1nickt (Canon) on Jun 28, 2017 at 07:57 UTC | |
by snehit.ar (Beadle) on Jun 28, 2017 at 10:43 UTC |