<?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: ksh TIME stamp compare in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339444#M683718</link>
    <description>&lt;!--!*#--&gt;Hi (again) Ratzie:&lt;BR /&gt;&lt;BR /&gt;Perl can make your task painless.&lt;BR /&gt;&lt;BR /&gt;# cat ./datediff&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use Date::Calc qw(Delta_DHMS);&lt;BR /&gt;my $date1 = shift or die "first  YYYYMMDDHHMMSS expected\n";&lt;BR /&gt;my $date2 = shift or die "second YYYYMMDDHHMMSS expected\n";&lt;BR /&gt;my ( $year1, $month1, $day1, $hour1, $min1, $sec1 )&lt;BR /&gt;    = unpack( "A4A2A2A2A2A2", $date1 );&lt;BR /&gt;my ( $year2, $month2, $day2, $hour2, $min2, $sec2 )&lt;BR /&gt;    = unpack( "A4A2A2A2A2A2", $date2 );&lt;BR /&gt;my ( $Dd, $Dh, $Dm, $Ds ) = Delta_DHMS(&lt;BR /&gt;    $year1, $month1, $day1, $hour1, $min1, $sec1,&lt;BR /&gt;    $year2, $month2, $day2, $hour2, $min2, $sec2&lt;BR /&gt;);&lt;BR /&gt;print "difference is $Dd days $Dh hours $Dm minutes $Ds seconds\n";&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./datediff 20090116185045 20090116183804&lt;BR /&gt;difference is 0 days 0 hours -12 minutes -41 seconds&lt;BR /&gt;&lt;BR /&gt;# ./datediff 20090116183804 20090116185045&lt;BR /&gt;difference is 0 days 0 hours 12 minutes 41 seconds&lt;BR /&gt;&lt;BR /&gt;That is, pass two date-time strings each in the format YYYMMDDHHMMSS&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Fri, 16 Jan 2009 22:49:00 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-01-16T22:49:00Z</dc:date>
    <item>
      <title>ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339438#M683712</link>
      <description>I have ksh script that stores two dates, each different variables as:&lt;BR /&gt;&lt;BR /&gt;$CURRENT  16-JAN-09-18:27:45&lt;BR /&gt;$APPLIED  16-JAN-09-18:24:41&lt;BR /&gt;&lt;BR /&gt;I want to subtract $CURRENT from $APPLIED&lt;BR /&gt;&lt;BR /&gt;All, there may be a case where APPLIED is NULL.&lt;BR /&gt;So I need to put an exception in that.&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jan 2009 18:31:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339438#M683712</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2009-01-16T18:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339439#M683713</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;And I assume that you know how you want to "subtract" these dates :-) ?&lt;BR /&gt;&lt;BR /&gt;You asked how to test if one of the variables is "null".  By that, I assume you mean "empty" in the shell context.&lt;BR /&gt;&lt;BR /&gt;# [ -z "${APPLIED}" ] &amp;amp;&amp;amp; echo "APPLIED is empty" || echo "APPLIED is set"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 16 Jan 2009 18:50:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339439#M683713</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-01-16T18:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339440#M683714</link>
      <description>So I changed the date format to:&lt;BR /&gt;&lt;BR /&gt;This is current: 090116185045&lt;BR /&gt;This is applied: 090116183804&lt;BR /&gt;&lt;BR /&gt;Just looking for the arithmetic to find difference</description>
      <pubDate>Fri, 16 Jan 2009 18:52:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339440#M683714</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2009-01-16T18:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339441#M683715</link>
      <description>&lt;P&gt;&amp;gt;DIFF=$(($CURRENT - $APPLIED))&lt;BR /&gt;&lt;BR /&gt;This will give you a difference with correct ordering but it isn't the normal distance metric for time in seconds. You can find differences but your distance metric is for some 5 dimensional phase space on your time units.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2011 04:32:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339441#M683715</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-05T04:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339442#M683716</link>
      <description>DIFF=$(($CURRENT - $APPLIED))&lt;BR /&gt;&lt;BR /&gt;I spoke too soon, I know it was too easy.&lt;BR /&gt;I have now changed it to just days &amp;amp; minutes that I am pulling from the oracle database into a file, so the output looks like:&lt;BR /&gt;DDMM&lt;BR /&gt;&lt;BR /&gt;But, yikes, now I get into time conversion.&lt;BR /&gt;Because if I take:&lt;BR /&gt;CURRENT is: 162201&lt;BR /&gt;APPLY is:   162108&lt;BR /&gt;It comes back with 93 minutes difference.&lt;BR /&gt;Which is wrong.</description>
      <pubDate>Fri, 16 Jan 2009 22:14:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339442#M683716</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2009-01-16T22:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339443#M683717</link>
      <description>Sorry date format is:&lt;BR /&gt;DDHH24MI&lt;BR /&gt;&lt;BR /&gt;Which gives me:&lt;BR /&gt;162215&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jan 2009 22:18:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339443#M683717</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2009-01-16T22:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339444#M683718</link>
      <description>&lt;!--!*#--&gt;Hi (again) Ratzie:&lt;BR /&gt;&lt;BR /&gt;Perl can make your task painless.&lt;BR /&gt;&lt;BR /&gt;# cat ./datediff&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use Date::Calc qw(Delta_DHMS);&lt;BR /&gt;my $date1 = shift or die "first  YYYYMMDDHHMMSS expected\n";&lt;BR /&gt;my $date2 = shift or die "second YYYYMMDDHHMMSS expected\n";&lt;BR /&gt;my ( $year1, $month1, $day1, $hour1, $min1, $sec1 )&lt;BR /&gt;    = unpack( "A4A2A2A2A2A2", $date1 );&lt;BR /&gt;my ( $year2, $month2, $day2, $hour2, $min2, $sec2 )&lt;BR /&gt;    = unpack( "A4A2A2A2A2A2", $date2 );&lt;BR /&gt;my ( $Dd, $Dh, $Dm, $Ds ) = Delta_DHMS(&lt;BR /&gt;    $year1, $month1, $day1, $hour1, $min1, $sec1,&lt;BR /&gt;    $year2, $month2, $day2, $hour2, $min2, $sec2&lt;BR /&gt;);&lt;BR /&gt;print "difference is $Dd days $Dh hours $Dm minutes $Ds seconds\n";&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./datediff 20090116185045 20090116183804&lt;BR /&gt;difference is 0 days 0 hours -12 minutes -41 seconds&lt;BR /&gt;&lt;BR /&gt;# ./datediff 20090116183804 20090116185045&lt;BR /&gt;difference is 0 days 0 hours 12 minutes 41 seconds&lt;BR /&gt;&lt;BR /&gt;That is, pass two date-time strings each in the format YYYMMDDHHMMSS&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 16 Jan 2009 22:49:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339444#M683718</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-01-16T22:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: ksh TIME stamp compare</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339445#M683719</link>
      <description>*******&lt;BR /&gt;But, yikes, now I get into time conversion.&lt;BR /&gt;Because if I take:&lt;BR /&gt;CURRENT is: 162201&lt;BR /&gt;APPLY is: 162108&lt;BR /&gt;It comes back with 93 minutes difference.&lt;BR /&gt;Which is wrong.&lt;BR /&gt;********&lt;BR /&gt;&lt;BR /&gt;When you are just subtracting a number, yes the difference is 93.&lt;BR /&gt;&lt;BR /&gt;The problem is that the shell has absolutely NO CLUE that what you have is a date/time.&lt;BR /&gt;&lt;BR /&gt;Think about it like this: &lt;BR /&gt;&lt;BR /&gt;162,201 - 162,108 = 93.&lt;BR /&gt;&lt;BR /&gt;James' solution above should do what you require.</description>
      <pubDate>Fri, 16 Jan 2009 22:54:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-time-stamp-compare/m-p/4339445#M683719</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2009-01-16T22:54:44Z</dc:date>
    </item>
  </channel>
</rss>

