<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to add two Datetime RANGES ? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846938#M97990</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I think Steve Lewis's solution is the most direct.&lt;BR /&gt;&lt;BR /&gt;SEP, while Clay's 'caljd' is very useful, it doesn't addresss the need for time delta computation.&lt;BR /&gt;&lt;BR /&gt;If I was presented with this data in a file, I'd use perl --- most probably the Delta_DHMS function of 'Date::Calc' available from CPAN.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Mon, 21 Aug 2006 06:57:50 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-08-21T06:57:50Z</dc:date>
    <item>
      <title>How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846934#M97986</link>
      <description>My values in a table are --&amp;gt;&lt;BR /&gt;2006-07-01 07:10:22 2006-07-01 09:11:26&lt;BR /&gt;2006-07-01 08:10:22 2006-07-01 12:11:26&lt;BR /&gt;&lt;BR /&gt;I want to find the interval of each row and add the intervals. How can it be done ?&lt;BR /&gt;We have to be careful about the overlapping date time.&lt;BR /&gt;The result should be in Hrs:Min:Sec format.&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2006 02:09:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846934#M97986</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-21T02:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846935#M97987</link>
      <description>create table d (f1 integer, dt1 datetime year to second, dt2 datetime year to second);&lt;BR /&gt;&lt;BR /&gt;insert into d values( 1 , "2006-07-01 07:10:22" , "2006-07-01 09:11:26" );&lt;BR /&gt;insert into d values( 2 , "2006-07-01 08:10:22" , "2006-07-01 12:11:26" );&lt;BR /&gt;&lt;BR /&gt;select ((x.dt2 -  x.dt1) + (y.dt2 - y.dt1) ) from d x, d y where x.f1=1 and y.f1=2 ;&lt;BR /&gt;&lt;BR /&gt;Gives the following output:&lt;BR /&gt;&lt;BR /&gt;(expression)&lt;BR /&gt;&lt;BR /&gt;        0 06:02:08&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2006 03:35:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846935#M97987</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2006-08-21T03:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846936#M97988</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;I've always found the most reliable way to do date calculations is to use &lt;A href="http://www.hpux.ws/merijn/caljd.sh" target="_blank"&gt;http://www.hpux.ws/merijn/caljd.sh&lt;/A&gt; and let it do calculation after using awk to extract the dates out of the file.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Mon, 21 Aug 2006 03:46:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846936#M97988</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-08-21T03:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846937#M97989</link>
      <description>Steven,&lt;BR /&gt;&lt;BR /&gt;I don't want the overlapping value.&lt;BR /&gt;I hope you are understanding me.</description>
      <pubDate>Mon, 21 Aug 2006 04:22:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846937#M97989</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-21T04:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846938#M97990</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I think Steve Lewis's solution is the most direct.&lt;BR /&gt;&lt;BR /&gt;SEP, while Clay's 'caljd' is very useful, it doesn't addresss the need for time delta computation.&lt;BR /&gt;&lt;BR /&gt;If I was presented with this data in a file, I'd use perl --- most probably the Delta_DHMS function of 'Date::Calc' available from CPAN.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 21 Aug 2006 06:57:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846938#M97990</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-21T06:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846939#M97991</link>
      <description>Steve has not taken account of overlapping values in date time.&lt;BR /&gt;I don't want the overlapping value in the final result.</description>
      <pubDate>Mon, 21 Aug 2006 07:14:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846939#M97991</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-21T07:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846940#M97992</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you don't want overlapping times be added,&lt;BR /&gt;simply check, if the end time of the first log entry is after the start time of the next.&lt;BR /&gt;If that is the case, use the end time of the previous line as the starting time of the next. In that way you can keep parsing line by line.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Mon, 21 Aug 2006 07:32:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846940#M97992</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-08-21T07:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846941#M97993</link>
      <description>&lt;BR /&gt;This PERL script might do the trick.&lt;BR /&gt;Day transition NOT test, and will not work for overlap.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sub seconds {($h,$m,$s)=split /:/,@_[0]; return $h*3600+$m*60+$s}&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;($bd,$bt,$ed,$et) = split;&lt;BR /&gt;$b = &amp;amp;seconds ($bt);&lt;BR /&gt;$e = &amp;amp;seconds ($et);&lt;BR /&gt;$b -= 86400 if ($bd lt $ed);&lt;BR /&gt;$b = $last if ($b &amp;lt; $last);&lt;BR /&gt;$last = $e;&lt;BR /&gt;$time += ($e - $b);&lt;BR /&gt;print "b=$b, e=$e, t=$time\n";&lt;BR /&gt;}&lt;BR /&gt;print "total time = $time\n";&lt;BR /&gt;&lt;BR /&gt;$ perl tmp.pl tmp.txt&lt;BR /&gt;b=25822, e=33086, t=7264&lt;BR /&gt;b=33086, e=43886, t=18064&lt;BR /&gt;total time = 18064&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2006 07:55:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846941#M97993</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-08-21T07:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to add two Datetime RANGES ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846942#M97994</link>
      <description>I was close. The overlap already worked.&lt;BR /&gt;The following works with a simple date change.&lt;BR /&gt;Overlap + date change does not work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $time = 0;&lt;BR /&gt;&lt;BR /&gt;sub seconds {my ($h,$m,$s)=split /:/,$_[0]; return $h*3600+$m*60+$s}&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;my $last = 0;&lt;BR /&gt;my ($bd,$bt,$ed,$et) = split;&lt;BR /&gt;my $b = &amp;amp;seconds ($bt);&lt;BR /&gt;my $e = &amp;amp;seconds ($et);&lt;BR /&gt;$b = $last if ($b &amp;lt; $last);&lt;BR /&gt;$b -= 86400 if ($bd lt $ed);&lt;BR /&gt;$last = $e;&lt;BR /&gt;# my $elapsed = ($e - $b);&lt;BR /&gt;$time += ($e - $b);&lt;BR /&gt;# print "b=$b, e=$e, elapsed=$elapsed, t=$time\n";&lt;BR /&gt;}&lt;BR /&gt;print "total time = $time\n";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#cat tmp.txt&lt;BR /&gt;2006-07-01 07:10:22 2006-07-01 09:11:26&lt;BR /&gt;2006-07-01 08:10:22 2006-07-01 12:11:26&lt;BR /&gt;2006-07-01 23:00:00 2006-07-02 00:10:00&lt;BR /&gt;2006-07-02 07:50:50 2006-07-02 08:20:20&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#perl tmp.pl tmp.txt&lt;BR /&gt;b=25822, e=33086, elapsed=7264, t=7264&lt;BR /&gt;b=29422, e=43886, elapsed=14464, t=21728&lt;BR /&gt;b=-3600, e=600, elapsed=4200, t=25928&lt;BR /&gt;b=28250, e=30020, elapsed=1770, t=27698&lt;BR /&gt;total time = 27698&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2006 09:01:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-two-datetime-ranges/m-p/3846942#M97994</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-08-21T09:01:25Z</dc:date>
    </item>
  </channel>
</rss>

