<?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: finding difference between 2 given time. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106790#M863665</link>
    <description>HI Clay,&lt;BR /&gt;&lt;BR /&gt;I used your solution for calculating the time difference between 2 times successfully in HP-UNIX but it is giving some errors while using the same solution in SUN OS. The error is :&lt;BR /&gt;&lt;BR /&gt;syntax error at line 6: `(' unexpected&lt;BR /&gt;&lt;BR /&gt;Can you please help. I know this forum is for HP-UX but just wanted to know if you could help me.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sat, 23 Oct 2004 19:48:01 GMT</pubDate>
    <dc:creator>Anand_30</dc:creator>
    <dc:date>2004-10-23T19:48:01Z</dc:date>
    <item>
      <title>finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106782#M863657</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am writing a script which genrates the start time and the end time of some transactions. I need to find the difference between them. How do I accomplish it. For example one of the start time and end time are as follows:&lt;BR /&gt;&lt;BR /&gt;start time = 021037 (2nd hour, 10th min and 37th sec)&lt;BR /&gt;end time = 021206 (2nd hour, 12th min and 06th sec)&lt;BR /&gt;&lt;BR /&gt;How do I find the difference (89 sec) in the script.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2003 13:24:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106782#M863657</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-10-30T13:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106783#M863658</link>
      <description>I would use the built-in shell variable SECONDS for this assuming sh or ksh.  &lt;BR /&gt;&lt;BR /&gt;It starts at zero when the script runs.  So if you have two portions of a script you want to time, you could use:&lt;BR /&gt;&lt;BR /&gt;&lt;SOME commands="" here=""&gt;&lt;BR /&gt;let CHECKPOINT=$SECONDS&lt;BR /&gt;echo "Elapsed time for fisrt operation is $CHECKPOINT seconds"&lt;BR /&gt;&lt;SOME commands="" here=""&gt;&lt;BR /&gt;let CHECKPOINT=${SECONDS}-${CHECKPOINT}&lt;BR /&gt;echo "Elapsed time for second operation is $CHECKPOINT seconds"&lt;BR /&gt;&lt;BR /&gt;You can also reset the SECONDS variable to zero at key points as well if you prefer.&lt;BR /&gt;&lt;/SOME&gt;&lt;/SOME&gt;</description>
      <pubDate>Thu, 30 Oct 2003 13:32:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106783#M863658</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2003-10-30T13:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106784#M863659</link>
      <description>Andy,&lt;BR /&gt;&lt;BR /&gt;What about using the time command and wrapping all your transactions into a script:&lt;BR /&gt;&lt;BR /&gt;time scriptname&lt;BR /&gt;&lt;BR /&gt;real    0m0.25s&lt;BR /&gt;user    0m0.02s&lt;BR /&gt;sys     0m0.02s&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Where scriptname contains all your transactions.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2003 13:54:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106784#M863659</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-10-30T13:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106785#M863660</link>
      <description>My script actually retrieves the start time and the end time of transaction from the logs.&lt;BR /&gt;&lt;BR /&gt;for example:-&lt;BR /&gt;&lt;BR /&gt;IVR Start Time=195415,IVR End Time=195535&lt;BR /&gt;&lt;BR /&gt;is one of the output created by my script.&lt;BR /&gt;&lt;BR /&gt;Now I would need to find the difference between 195535 and 195415 which is 80sec.&lt;BR /&gt;&lt;BR /&gt;How can I do this in a script.&lt;BR /&gt;&lt;BR /&gt;Sorry for conveying improper message in my previous mail.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Anand.&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2003 14:10:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106785#M863660</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-10-30T14:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106786#M863661</link>
      <description>This should be rather easy leveraging awk (and I do assume that your input strings are 6 chars in length):&lt;BR /&gt;&lt;BR /&gt;--------------------------------- &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;calc_seconds()&lt;BR /&gt;{&lt;BR /&gt;  typeset TIME=${1}&lt;BR /&gt;  shift&lt;BR /&gt;  typeset -i10 OUT=$(echo "${TIME}" | awk '{ print ((substr($0,1,2) + 0) * 3600) + ((substr($0,3,2) + 0) * 60) + (substr($0,5,2) + 0) }')&lt;BR /&gt;  typeset -i10 STAT=${?}&lt;BR /&gt;  echo "${OUT}"&lt;BR /&gt;  return ${STAT}&lt;BR /&gt;} # calc_seconds&lt;BR /&gt;&lt;BR /&gt;TIME1=021037&lt;BR /&gt;TIME2=021206&lt;BR /&gt;&lt;BR /&gt;DIFF=$(( $(calc_seconds ${TIME2}) - $(calc_seconds ${TIME1}) ))&lt;BR /&gt;echo "Diff = ${DIFF} seconds." &lt;BR /&gt;------------------------------------&lt;BR /&gt;&lt;BR /&gt;Note: I am not out of my mind (more or less) with those seemingly stupid substr() + 0's. The + 0 is a standard awk idiom to force an expression into a numeric context.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2003 14:14:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106786#M863661</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-10-30T14:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106787#M863662</link>
      <description>&lt;BR /&gt;In perl:&lt;BR /&gt;&lt;BR /&gt;#!/bin/perl&lt;BR /&gt;sub seconds{ &lt;BR /&gt; my($t) = @_;&lt;BR /&gt; return ((60*substr($t,0,2)+substr($t,2,2))*60+substr($t,4,2)) &lt;BR /&gt;}&lt;BR /&gt;$begin = shift @ARGV;&lt;BR /&gt;$end   = shift @ARGV;&lt;BR /&gt;$diff  = seconds( $end ) - seconds( $begin );&lt;BR /&gt;$diff += seconds("240000") if ($diff &amp;lt; 0);&lt;BR /&gt;print "Diff = $diff\n";&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2003 14:23:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106787#M863662</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2003-10-30T14:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106788#M863663</link>
      <description>Anand,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;will you ever have to deal with a start time just before midnite and an end in the next day?&lt;BR /&gt;&lt;BR /&gt;If so you will need to augment Clay's solution with an "add 86400 to diff if it is negative" like my perl answer does.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2003 14:51:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106788#M863663</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2003-10-30T14:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106789#M863664</link>
      <description>Hi Andy,&lt;BR /&gt;for this kind of problem usually I used two functions I've created: ResTime &amp;amp; GetTime&lt;BR /&gt;&lt;BR /&gt;######################################&lt;BR /&gt;restime() {&lt;BR /&gt;######################################&lt;BR /&gt;# Resets var&lt;BR /&gt;SECONDS=0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;######################################&lt;BR /&gt;gettime() {&lt;BR /&gt;######################################&lt;BR /&gt;# Returns the time spent (hh:mm:ss) by commands between restime and itself #&lt;BR /&gt;sec=$SECONDS&lt;BR /&gt;hh=$(expr $sec / 3600)&lt;BR /&gt;mm=$(expr \( $sec - 3600 \* $hh \) / 60)&lt;BR /&gt;ss=$(expr $sec - 3600 \* $hh - 60 \* $mm)&lt;BR /&gt;printf "%.2d:%.2d:%.2d\n" $hh $mm $ss&lt;BR /&gt;unset sec hh mm ss&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In your script put the restime at the top of teh script and at the end you can type:&lt;BR /&gt;echo $(gettime) to see how much time your script used.&lt;BR /&gt;&lt;BR /&gt;This are my 2 cents.&lt;BR /&gt;Art&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Oct 2003 04:22:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106789#M863664</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2003-10-31T04:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106790#M863665</link>
      <description>HI Clay,&lt;BR /&gt;&lt;BR /&gt;I used your solution for calculating the time difference between 2 times successfully in HP-UNIX but it is giving some errors while using the same solution in SUN OS. The error is :&lt;BR /&gt;&lt;BR /&gt;syntax error at line 6: `(' unexpected&lt;BR /&gt;&lt;BR /&gt;Can you please help. I know this forum is for HP-UX but just wanted to know if you could help me.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Oct 2004 19:48:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106790#M863665</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2004-10-23T19:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106791#M863666</link>
      <description>I don't have a Solaris box to play on but here's a couple of suggestions:&lt;BR /&gt;&lt;BR /&gt;1. Change the "shebang" to #!/usr/bin/ksh.&lt;BR /&gt;B. Change the typeset -i10 XXX= to simply typeset -i XXX=.&lt;BR /&gt;III. Change 'awk' to 'nawk'. Under Solaris, awk is 'oawk' (Old Awk) so that nawk must be invoked explicitly. On HP-UX, awk is 'nawk' (New Awk). By the way, new awk is at least 15 years old and oawk is considered obsolete but I guess someone forgot to tell Sun.&lt;BR /&gt;&lt;BR /&gt;Okay, that's 3 suggestions but who's counting.</description>
      <pubDate>Sun, 24 Oct 2004 14:31:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106791#M863666</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-10-24T14:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: finding difference between 2 given time.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106792#M863667</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you did not use copy/paste to transfer the program to solaris? Maybe you forgot to reconnect the typeset line which stretches overt two line.&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;typeset -i10 OUT=$(echo "${TIME}" | awk '{ print ((substr($0,1,2) + 0) * 3600) + ((substr($0,3,2) + 0) * 60) + (substr($0,5,2) + 0) }')&lt;BR /&gt;</description>
      <pubDate>Sun, 24 Oct 2004 16:22:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-difference-between-2-given-time/m-p/3106792#M863667</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-10-24T16:22:04Z</dc:date>
    </item>
  </channel>
</rss>

