<?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: Script help - Dates in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712295#M60928</link>
    <description>That's fairly easy too; we just take advantage of the shell's arrays:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;MO[01]="Jan"&lt;BR /&gt;MO[02]="Feb"&lt;BR /&gt;MO[03]="Mar"&lt;BR /&gt;MO[04]="Apr"&lt;BR /&gt;MO[05]="May"&lt;BR /&gt;MO[06]="Jun"&lt;BR /&gt;MO[07]="Jul"&lt;BR /&gt;MO[08]="Aug"&lt;BR /&gt;MO[09]="Sep"&lt;BR /&gt;MO[10]="Oct"&lt;BR /&gt;MO[11]="Nov"&lt;BR /&gt;MO[12]="Dec"&lt;BR /&gt;&lt;BR /&gt;DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)&lt;BR /&gt;echo "DAY=${DAY}"&lt;BR /&gt;MONTH=${MO[$(caljd.sh -M $(caljd.sh -p 14))]}&lt;BR /&gt;echo "Month=${MONTH}"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 26 Apr 2002 20:55:21 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2002-04-26T20:55:21Z</dc:date>
    <item>
      <title>Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712287#M60920</link>
      <description>I have a faxing app that I need to write a simple script to purge the outbound fax entries.  The command used is as follows:&lt;BR /&gt;&lt;BR /&gt;faxdbdel -OUTBOUND -to YYMMDD&lt;BR /&gt;&lt;BR /&gt;The user wants to keep 2 weeks worth in the db.  I figured I would write a cron script which is called daily to accomplish this, but I'm having some problems trying to load the command with the correct day (DD) of 2 weeks ago.  Any ideas?&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;Greg</description>
      <pubDate>Fri, 26 Apr 2002 19:29:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712287#M60920</guid>
      <dc:creator>Greg Stark_1</dc:creator>
      <dc:date>2002-04-26T19:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712288#M60921</link>
      <description>Hi Greg,&lt;BR /&gt;To get the day of month is&lt;BR /&gt;date +%d day of month&lt;BR /&gt;date +%a for week day etc..&lt;BR /&gt;&lt;BR /&gt;If you don't mind post your script or part of script which has problem.&lt;BR /&gt;&lt;BR /&gt;Sachin</description>
      <pubDate>Fri, 26 Apr 2002 19:34:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712288#M60921</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2002-04-26T19:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712289#M60922</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm certainly not going to take credit for this, but Mr Stephenson's 'caljd.sh' script will do this job. I'm sure you find it easily by searching, or it may even be posted by Clay himself.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;~Michael~</description>
      <pubDate>Fri, 26 Apr 2002 19:36:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712289#M60922</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2002-04-26T19:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712290#M60923</link>
      <description>Hi Greg: This rather cryptic shell line will do the trick:&lt;BR /&gt;&lt;BR /&gt;DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)&lt;BR /&gt;echo "DAY=${DAY}"&lt;BR /&gt;&lt;BR /&gt;The inner caljd.sh returns the Julian Day 14 days ago and the outer caljd.sh says format in YYYY MM DD format (-e) and reove the spaces (-s) to yield YYYYMMDD. The cut then says returns characters 3 to the end of string or YYMMDD - just what you asked for.&lt;BR /&gt;&lt;BR /&gt;See the attached caljd.sh. Caljd.sh -u will give full usage.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Apr 2002 19:40:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712290#M60923</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-26T19:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712291#M60924</link>
      <description>I agree, basically Clay's script is the defacto standard for date calculations in this forum.&lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
      <pubDate>Fri, 26 Apr 2002 19:40:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712291#M60924</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-04-26T19:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712292#M60925</link>
      <description>Woo nice script Mr. Clay. &lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 26 Apr 2002 20:03:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712292#M60925</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2002-04-26T20:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712293#M60926</link>
      <description>I agree, I wish I had it for some previous scripts.&lt;BR /&gt;&lt;BR /&gt;Thanks,again.</description>
      <pubDate>Fri, 26 Apr 2002 20:06:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712293#M60926</guid>
      <dc:creator>Greg Stark_1</dc:creator>
      <dc:date>2002-04-26T20:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712294#M60927</link>
      <description>Ok, one more question.  With the help of caljd.sh I can return the the month of the year from 14 days ago in a 2-digit form.  Besides using a long case or if/elsif statement, is there an easy way to convert a 2-digit month to the corresponding 3 letter string?&lt;BR /&gt;&lt;BR /&gt;For instance:&lt;BR /&gt;04=Apr&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;Greg</description>
      <pubDate>Fri, 26 Apr 2002 20:40:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712294#M60927</guid>
      <dc:creator>Greg Stark_1</dc:creator>
      <dc:date>2002-04-26T20:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712295#M60928</link>
      <description>That's fairly easy too; we just take advantage of the shell's arrays:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;MO[01]="Jan"&lt;BR /&gt;MO[02]="Feb"&lt;BR /&gt;MO[03]="Mar"&lt;BR /&gt;MO[04]="Apr"&lt;BR /&gt;MO[05]="May"&lt;BR /&gt;MO[06]="Jun"&lt;BR /&gt;MO[07]="Jul"&lt;BR /&gt;MO[08]="Aug"&lt;BR /&gt;MO[09]="Sep"&lt;BR /&gt;MO[10]="Oct"&lt;BR /&gt;MO[11]="Nov"&lt;BR /&gt;MO[12]="Dec"&lt;BR /&gt;&lt;BR /&gt;DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)&lt;BR /&gt;echo "DAY=${DAY}"&lt;BR /&gt;MONTH=${MO[$(caljd.sh -M $(caljd.sh -p 14))]}&lt;BR /&gt;echo "Month=${MONTH}"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Apr 2002 20:55:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712295#M60928</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-26T20:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712296#M60929</link>
      <description>Hi again Greg:&lt;BR /&gt;&lt;BR /&gt;Yet another way to convert 04 to "Apr" although I like the previous method better; it's less obscure.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SMONTH="???JanFebMarAprMayJunJulAugSepOctNovDec"&lt;BR /&gt;&lt;BR /&gt;DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)&lt;BR /&gt;echo "DAY=${DAY}"&lt;BR /&gt;&lt;BR /&gt;NMONTH=$(caljd.sh -M $(caljd.sh -p 14))&lt;BR /&gt;OFFSET=$(((${NMONTH} * 3) + 1))&lt;BR /&gt;STOP=$((${OFFSET} + 2))&lt;BR /&gt;MONTH=$(echo ${SMONTH} | cut -c ${OFFSET}-${STOP})&lt;BR /&gt;echo "MONTH=${MONTH}"&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Apr 2002 21:24:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712296#M60929</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-26T21:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712297#M60930</link>
      <description>I think I follow them both, but why all the ?'s in the SMONTH string?&lt;BR /&gt;&lt;BR /&gt;Thank again, &lt;BR /&gt;Greg</description>
      <pubDate>Fri, 26 Apr 2002 21:30:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712297#M60930</guid>
      <dc:creator>Greg Stark_1</dc:creator>
      <dc:date>2002-04-26T21:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712298#M60931</link>
      <description>Hi Greg:&lt;BR /&gt;&lt;BR /&gt;Without the dummy values for month 0 the offset calculations become offset = ((month - 1) * 3) + 1 - even more messy.</description>
      <pubDate>Sat, 27 Apr 2002 00:39:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712298#M60931</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-27T00:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - Dates</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712299#M60932</link>
      <description>Okay Greg last time:&lt;BR /&gt;&lt;BR /&gt;Your last question did make me realize that there was a better way still to do the offset into the month string. Use two '?'s and then it is not necessary to subtract 1 so that offset = (month * 3).&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SMONTH="??JanFebMarAprMayJunJulAugSepOctNovDec" &lt;BR /&gt;&lt;BR /&gt;DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-) &lt;BR /&gt;echo "DAY=${DAY}" &lt;BR /&gt;&lt;BR /&gt;NMONTH=$(caljd.sh -M $(caljd.sh -p 14)) &lt;BR /&gt;OFFSET=$((${NMONTH} * 3)) &lt;BR /&gt;STOP=$((${OFFSET} + 2)) &lt;BR /&gt;MONTH=$(echo ${SMONTH} | cut -c ${OFFSET}-${STOP}) &lt;BR /&gt;echo "MONTH=${MONTH}" &lt;BR /&gt;</description>
      <pubDate>Sat, 27 Apr 2002 14:03:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-dates/m-p/2712299#M60932</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-04-27T14:03:04Z</dc:date>
    </item>
  </channel>
</rss>

