<?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 compare dates in a text file ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732058#M65701</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This should be fairly straightforward...&lt;BR /&gt;&lt;BR /&gt;Get today's date in the format yyyymmdd:&lt;BR /&gt;TODAY=$(date +%Y%m%d)&lt;BR /&gt;&lt;BR /&gt;Then for each record in your file, convert the date to the same format then compare them:&lt;BR /&gt;&lt;BR /&gt;cat &lt;TEXTFILE&gt; | {&lt;BR /&gt;while read X TAPE X X X MM DD YYYY&lt;BR /&gt;# convert Month in MM to numeric&lt;BR /&gt;do&lt;BR /&gt;case ${MM} in&lt;BR /&gt;Jan) M=01;;&lt;BR /&gt;Feb) M=02;;&lt;BR /&gt;Mar) M=03;;&lt;BR /&gt;Apr) M=04;;&lt;BR /&gt;May) M=05;;&lt;BR /&gt;Jun) M=06;;&lt;BR /&gt;Jul) M=07;;&lt;BR /&gt;Aug) M=08;;&lt;BR /&gt;Sep) M=09;;&lt;BR /&gt;Oct) M=10;;&lt;BR /&gt;Nov) M=11;;&lt;BR /&gt;Dec) M=12;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;let YYYYMMDD=$(YYYY}${MM}${DD}&lt;BR /&gt;&lt;BR /&gt;if (( YYYYMMDD &amp;lt; TODAY }};&lt;BR /&gt;then &lt;TAPE&gt;&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;/TAPE&gt;&lt;/TEXTFILE&gt;</description>
    <pubDate>Mon, 27 May 2002 10:54:26 GMT</pubDate>
    <dc:creator>John Palmer</dc:creator>
    <dc:date>2002-05-27T10:54:26Z</dc:date>
    <item>
      <title>How to compare dates in a text file ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732056#M65699</link>
      <description>Dear Colleagues,&lt;BR /&gt;&lt;BR /&gt;I have a text file containing tape barcode labels and the date they expire. Typically looks like this : &lt;BR /&gt;&lt;BR /&gt;Barcode: 000001 Expire Date: Wed Mar 28 2001&lt;BR /&gt;Barcode: 000001 Expire Date: Thu May 16 2002&lt;BR /&gt;&lt;BR /&gt;I'm writing a script which searches this text file and identifies all tapes which have expired. To do this I need a way of taking the sysdate, comparing it with the dates in the file and identifying all dates prior to the sysdate. Is there a way of doing this? &lt;BR /&gt;Many thanks and regards,&lt;BR /&gt;Preet :-)</description>
      <pubDate>Mon, 27 May 2002 10:21:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732056#M65699</guid>
      <dc:creator>Preet Dhillon</dc:creator>
      <dc:date>2002-05-27T10:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare dates in a text file ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732057#M65700</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;here an awk script for you:&lt;BR /&gt;&lt;BR /&gt;awk -vcday=$(date +%d) -vcmon=$(date +%m) -vcyear=$(date +%Y) '{&lt;BR /&gt;day=$(NF-1)&lt;BR /&gt;if($(NF-2)=="Jan") mon=1&lt;BR /&gt;if($(NF-2)=="Feb") mon=2&lt;BR /&gt;if($(NF-2)=="Mar") mon=3&lt;BR /&gt;if($(NF-2)=="Apr") mon=4&lt;BR /&gt;if($(NF-2)=="May") mon=5&lt;BR /&gt;if($(NF-2)=="Jun") mon=6&lt;BR /&gt;if($(NF-2)=="Jul") mon=7&lt;BR /&gt;if($(NF-2)=="Aug") mon=8&lt;BR /&gt;if($(NF-2)=="Sep") mon=9&lt;BR /&gt;if($(NF-2)=="Oct") mon=10&lt;BR /&gt;if($(NF-2)=="Nov") mon=11&lt;BR /&gt;if($(NF-2)=="Dec") mon=12&lt;BR /&gt;year=$(NF)&lt;BR /&gt;expire="No"&lt;BR /&gt;if(year &amp;lt; cyear)&lt;BR /&gt;  expire="Yes"&lt;BR /&gt;else if(year == cyear)&lt;BR /&gt;{&lt;BR /&gt;   if(mon &amp;lt; cmon)&lt;BR /&gt;      expire="Yes"&lt;BR /&gt;   else if(mon == cmon)&lt;BR /&gt;   {&lt;BR /&gt;     if(day &amp;lt; cday)&lt;BR /&gt;       expire="Yes"&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;print $0 ": Expire = " expire&lt;BR /&gt;}' &lt;TEXT_FILE&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/TEXT_FILE&gt;</description>
      <pubDate>Mon, 27 May 2002 10:50:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732057#M65700</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2002-05-27T10:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare dates in a text file ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732058#M65701</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This should be fairly straightforward...&lt;BR /&gt;&lt;BR /&gt;Get today's date in the format yyyymmdd:&lt;BR /&gt;TODAY=$(date +%Y%m%d)&lt;BR /&gt;&lt;BR /&gt;Then for each record in your file, convert the date to the same format then compare them:&lt;BR /&gt;&lt;BR /&gt;cat &lt;TEXTFILE&gt; | {&lt;BR /&gt;while read X TAPE X X X MM DD YYYY&lt;BR /&gt;# convert Month in MM to numeric&lt;BR /&gt;do&lt;BR /&gt;case ${MM} in&lt;BR /&gt;Jan) M=01;;&lt;BR /&gt;Feb) M=02;;&lt;BR /&gt;Mar) M=03;;&lt;BR /&gt;Apr) M=04;;&lt;BR /&gt;May) M=05;;&lt;BR /&gt;Jun) M=06;;&lt;BR /&gt;Jul) M=07;;&lt;BR /&gt;Aug) M=08;;&lt;BR /&gt;Sep) M=09;;&lt;BR /&gt;Oct) M=10;;&lt;BR /&gt;Nov) M=11;;&lt;BR /&gt;Dec) M=12;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;let YYYYMMDD=$(YYYY}${MM}${DD}&lt;BR /&gt;&lt;BR /&gt;if (( YYYYMMDD &amp;lt; TODAY }};&lt;BR /&gt;then &lt;TAPE&gt;&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;/TAPE&gt;&lt;/TEXTFILE&gt;</description>
      <pubDate>Mon, 27 May 2002 10:54:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732058#M65701</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-05-27T10:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare dates in a text file ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732059#M65702</link>
      <description>Install Date::Calc for perl, available from &lt;A href="ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/Date/Date-Calc-5.0.tar.gz" target="_blank"&gt;ftp://download.xs4all.nl/pub/mirror/CPAN/modules/by-module/Date/Date-Calc-5.0.tar.gz&lt;/A&gt;</description>
      <pubDate>Mon, 27 May 2002 10:56:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732059#M65702</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-05-27T10:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare dates in a text file ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732060#M65703</link>
      <description>Hi John, &lt;BR /&gt;&lt;BR /&gt;Many thanks for your help with this. &lt;BR /&gt;Just a quick question - is the following line correct : &lt;BR /&gt;&lt;BR /&gt;if (( YYYYMMDD &amp;lt; TODAY }}; &lt;BR /&gt;&lt;BR /&gt;It looks like the open brackets (( and braces }} are not matched ? &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Preet</description>
      <pubDate>Mon, 27 May 2002 13:54:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732060#M65703</guid>
      <dc:creator>Preet Dhillon</dc:creator>
      <dc:date>2002-05-27T13:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare dates in a text file ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732061#M65704</link>
      <description>Problem solved guys, many thanks to all of you for responding so quickly - much appreciated as always. &lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Preet :-))</description>
      <pubDate>Mon, 27 May 2002 14:38:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-compare-dates-in-a-text-file/m-p/2732061#M65704</guid>
      <dc:creator>Preet Dhillon</dc:creator>
      <dc:date>2002-05-27T14:38:42Z</dc:date>
    </item>
  </channel>
</rss>

