<?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: Date Comparison in Korn Shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189852#M714090</link>
    <description>There is a contributed script to do this.&lt;BR /&gt;I think shell and perl versions are available.&lt;BR /&gt;&lt;BR /&gt;Go here...&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=13505" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=13505&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
    <pubDate>Thu, 12 Feb 2004 03:36:31 GMT</pubDate>
    <dc:creator>Graham Cameron_1</dc:creator>
    <dc:date>2004-02-12T03:36:31Z</dc:date>
    <item>
      <title>Date Comparison in Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189850#M714088</link>
      <description>I need to compare two date strings to see if they are more than 300 days different, I have to do this in Korn Shell cause the boss said so. The date strings look like '02/12/04'. I suppose what I really need is a tool or function to convert a date string to Unix seconds and then do my comparisons. Anyone got any clues.</description>
      <pubDate>Thu, 12 Feb 2004 02:07:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189850#M714088</guid>
      <dc:creator>Patrick Collins</dc:creator>
      <dc:date>2004-02-12T02:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Date Comparison in Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189851#M714089</link>
      <description>I don't know of a solution with ksh itself, unless you want to start real calculation with leap years etc. But with perl it can be done quite simple, using the timegm function.&lt;BR /&gt;&lt;BR /&gt;#!/usr/local/bin/perl&lt;BR /&gt;use Time::Local;&lt;BR /&gt;&lt;BR /&gt;print timegm(0,0,0,$ARGV[0],ARGV[1]-1,ARGV[2]);&lt;BR /&gt;&lt;BR /&gt;This will print out the time in seconds sincs 1900. You need to call it with the time splitted. So you call it like this:&lt;BR /&gt;SECONDS=$(timesec.pl `echo $DATE1 | tr '/' ' '`)&lt;BR /&gt;&lt;BR /&gt;Then it's only a matter of comparing the seconds. You could of course do it all in perl...</description>
      <pubDate>Thu, 12 Feb 2004 03:10:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189851#M714089</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-02-12T03:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Date Comparison in Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189852#M714090</link>
      <description>There is a contributed script to do this.&lt;BR /&gt;I think shell and perl versions are available.&lt;BR /&gt;&lt;BR /&gt;Go here...&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=13505" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=13505&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Thu, 12 Feb 2004 03:36:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189852#M714090</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2004-02-12T03:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Date Comparison in Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189853#M714091</link>
      <description>Here's the way to do this although you will need the latest version (2.22) of caljd.sh to correctly interpret 2-digit years. Without the -C option year 04 would mean 4 CE rather than 2004 CE. We will turn those dates into Julian Days (days since Jan. 1, 4713 BCE) and then the comparisons are trivially easy.&lt;BR /&gt;&lt;BR /&gt;DT1="02/12/04"&lt;BR /&gt;DT2="12/31/05"&lt;BR /&gt;JDATE1=$(caljd.sh -S "/" -c -C ${DT1})&lt;BR /&gt;JDATE2=$(caljd.sh -S "/" -c -C ${DT2})&lt;BR /&gt;DIFF=$(( ${JDATE2} - ${JDATE1} ))&lt;BR /&gt;if [[ ${DIFF} -gt 300 ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "More than 300 days"&lt;BR /&gt;else&lt;BR /&gt;  echo "They ain't"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Invoke as caljd.sh -u for full usage. If you like, you could simply yank out the cal_jdate function and use it in your own script but you would then have to parse the date into month, day, and 4-digit year.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Feb 2004 10:12:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-comparison-in-korn-shell/m-p/3189853#M714091</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-02-12T10:12:59Z</dc:date>
    </item>
  </channel>
</rss>

