<?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 format in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466916#M360635</link>
    <description>&amp;gt;For e.g, on 1st Jan 2010, the script won't be able to zip from the 16th Dec files to 31st Dec files.&lt;BR /&gt;&amp;gt;How can my script take care of this last issue?&lt;BR /&gt;&lt;BR /&gt;How does your script handle the previous month, if in the same year?&lt;BR /&gt;I assume you just check if Dec and subtract one from the year.&lt;BR /&gt;&lt;BR /&gt;Have you looked at Clay's caljd script to date arithmetic?&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1232368" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1232368&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1173224" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1173224&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1158441" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1158441&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1101623" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1101623&lt;/A&gt;</description>
    <pubDate>Tue, 04 Aug 2009 07:08:38 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2009-08-04T07:08:38Z</dc:date>
    <item>
      <title>Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466903#M360622</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;MTHLESS="$((`date +%m`-1))"&lt;BR /&gt;&lt;BR /&gt;using the above command,I am able to get the current month -1, I would like to know whether it will work when it comes to January. Will I be able to get December as the output?&lt;BR /&gt;&lt;BR /&gt;Please advice.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Feng Lin</description>
      <pubDate>Mon, 27 Jul 2009 01:18:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466903#M360622</guid>
      <dc:creator>Fenglin</dc:creator>
      <dc:date>2009-07-27T01:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466904#M360623</link>
      <description>That is just a simple arithmetic calculation, so in January it will resolve as follows:&lt;BR /&gt;&lt;BR /&gt;01 - 1 = 0&lt;BR /&gt;&lt;BR /&gt;Which I suspect is not what you want...&lt;BR /&gt;&lt;BR /&gt;Why not install the GNU version of date which is available in the GNU coreutils package available here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/coreutils-7.4/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/coreutils-7.4/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;(Don't miss the runtime dependencies you need too)&lt;BR /&gt;&lt;BR /&gt;Once you have that you can easily do things like this:&lt;BR /&gt;&lt;BR /&gt;# /usr/local/coreutils/bin/date +%m&lt;BR /&gt;07&lt;BR /&gt;# /usr/local/coreutils/bin/date -d "last month" +%m&lt;BR /&gt;06&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Mon, 27 Jul 2009 08:02:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466904#M360623</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2009-07-27T08:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466905#M360624</link>
      <description>&amp;gt;Will I be able to get December as the output?&lt;BR /&gt;&lt;BR /&gt;You can get 12 if you do:&lt;BR /&gt;(( MTHLESS = ($(date +%m) + 11) % 12 + 1 ))</description>
      <pubDate>Mon, 27 Jul 2009 09:16:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466905#M360624</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-27T09:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466906#M360625</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;If the month is all that you want, you can do:&lt;BR /&gt;&lt;BR /&gt;# awk -v $(date +%m) 'BEGIN{MON-=1;MON=MON==0 ? 12 : MON;print MON}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 27 Jul 2009 10:51:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466906#M360625</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-27T10:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466907#M360626</link>
      <description>&amp;gt;JRF: awk -v $(date +%m) 'BEGIN{MON-=1;MON=MON==0 ? 12 : MON;print MON}'&lt;BR /&gt;&lt;BR /&gt;I'm not sure how using awk is better than a real shell's builtin arithmetic expressions using clock arithmetic (%)?&lt;BR /&gt;Also, I think you need to redirect stdin to /dev/null or add ";exit" to the end.</description>
      <pubDate>Mon, 27 Jul 2009 15:27:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466907#M360626</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-27T15:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466908#M360627</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: I'm not sure how using awk is better than a real shell's builtin arithmetic expressions using clock arithmetic (%)?&lt;BR /&gt;&lt;BR /&gt;I never said that is was.  I'm merely pointing out TIMTOWDI ;-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: Also, I think you need to redirect stdin to /dev/null or add ";exit" to the end.&lt;BR /&gt;&lt;BR /&gt;The BEGIN rule takes care of that _if_ I hadn't bungled the variable assignment:&lt;BR /&gt;&lt;BR /&gt;# awk -v MON=$(date +%m) 'BEGIN{MON-=1;MON=MON==0 ? 12 : MON;print MON}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 27 Jul 2009 15:38:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466908#M360627</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-27T15:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466909#M360628</link>
      <description>Hi All&lt;BR /&gt;&lt;BR /&gt;Thanks for the info. &lt;BR /&gt;&lt;BR /&gt;Now I have the following situation : -&lt;BR /&gt;&lt;BR /&gt;I have files with naming convention *yyyymmdd*. How am I going to take care of the zero(Jan - Sep) and one(Oct - Dec) for the month if I need to do housekeeping on those files?&lt;BR /&gt;&lt;BR /&gt;I intend to run the housekeeping job twice a month on the 1st and 16th of the month. 1st is to archive 16 - 31st day files, 16th is to archive 1 - 15th day files.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Feng Lin</description>
      <pubDate>Tue, 28 Jul 2009 00:24:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466909#M360628</guid>
      <dc:creator>Fenglin</dc:creator>
      <dc:date>2009-07-28T00:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466910#M360629</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; How am I going to take care of the zero(Jan - Sep) and one(Oct - Dec) for the month if I need to do housekeeping on those files?&lt;BR /&gt;&lt;BR /&gt;# awk -v MON=$(date +%m) 'BEGIN{MON-=1;MON=MON==0 ? 12 : MON;printf "%02d\n",MON}'&lt;BR /&gt;06&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 28 Jul 2009 00:39:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466910#M360629</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-28T00:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466911#M360630</link>
      <description>&amp;gt;JRF: The BEGIN rule takes care of that _if_ I hadn't bungled the variable assignment:&lt;BR /&gt;&lt;BR /&gt;I guess the way awk works is that it doesn't bother reading the input files if there are no pattern-action statements, other than BEGIN.&lt;BR /&gt;I don't know if this is documented, so I wouldn't depend on it.  The standard seems to say that if NO actions and patterns, then the files aren't read.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;How am I going to take care of the zero (fill) (Jan - Sep) and one(Oct - Dec) for the month&lt;BR /&gt;&lt;BR /&gt;typeset -Z2 MTHLESS # zero fill&lt;BR /&gt;(( MTHLESS = ($(date +%m) + 11) % 12 + 1 ))&lt;BR /&gt;echo $MTHLESS</description>
      <pubDate>Tue, 28 Jul 2009 01:03:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466911#M360630</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-28T01:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466912#M360631</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis: I guess the way awk works is that it doesn't bother reading the input files if there are no pattern-action statements, other than BEGIN.  I don't know if this is documented, so I wouldn't depend on it. The standard seems to say that if NO actions and patterns, then the files aren't read.&lt;BR /&gt;&lt;BR /&gt;I agree that the input file(s) are not read in the case of a BEGIN block with no pattern-action statements in the subsequent main block.  This is easy to demonstrate.  &lt;BR /&gt;&lt;BR /&gt;Of course, this behavior doesn't occur if an END block is declared either alone or in concert with a BEGIN block.  In that case, at least one file must be input.&lt;BR /&gt;&lt;BR /&gt;I concede that relying on these subtitles may lead to confusion and/or false expectations.  Hence it is probably best to amend the 'awk' snippet to:&lt;BR /&gt;&lt;BR /&gt;# awk -v MON=$(date +%m) 'BEGIN{MON-=1;MON=MON==0 ? 12 : MON;printf "%02d\n",MON}' /dev/null&lt;BR /&gt;&lt;BR /&gt;...and then (similarly) this works too:&lt;BR /&gt;&lt;BR /&gt;# awk -v MON=$(date +%m) 'END{MON-=1;MON=MON==0 ? 12 : MON;printf "%02d\n",MON}' /dev/null&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 28 Jul 2009 11:18:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466912#M360631</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-28T11:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466913#M360632</link>
      <description>Hi Dennis&lt;BR /&gt;&lt;BR /&gt;I am using ur method,typeset etc.....&lt;BR /&gt;&lt;BR /&gt;I should be getting 06 as the output for the current month,instead I am still getting 07.&lt;BR /&gt;&lt;BR /&gt;Please advice.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Feng Lin</description>
      <pubDate>Thu, 30 Jul 2009 01:23:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466913#M360632</guid>
      <dc:creator>Fenglin</dc:creator>
      <dc:date>2009-07-30T01:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466914#M360633</link>
      <description>&amp;gt;I should be getting 06 as the output for the current month, instead I am still getting 07.&lt;BR /&gt;&lt;BR /&gt;Oops, off by one:&lt;BR /&gt;(( MTHLESS = ($(date +%m) + (12-1-1)) % 12 + 1 ))&lt;BR /&gt;&lt;BR /&gt;The extra -1 and +1 bias the 0..11 to 1..12.  The first 12 is to prevent negative numbers because % is rem and not mod.&lt;BR /&gt;And of course the other -1, is the previous month.</description>
      <pubDate>Thu, 30 Jul 2009 01:51:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466914#M360633</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-07-30T01:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466915#M360634</link>
      <description>Hi All&lt;BR /&gt;&lt;BR /&gt;Many thanks for your response. I have one last question.&lt;BR /&gt;&lt;BR /&gt;I have 2 scripts, one running on the 1st, the other running on the 16th.&lt;BR /&gt;&lt;BR /&gt;1st is to zip from the 16th to 31st day of the month and 16th is to zip from the 1st to 15th day of the month.&lt;BR /&gt;&lt;BR /&gt;However,when the script 1st run for the next year, it won't be able to zip from the 16th to 31st day of last month.&lt;BR /&gt;For e.g, on 1st Jan 2010, the script won't be able to zip from the 16th dec files to 31st dec files.&lt;BR /&gt;&lt;BR /&gt;How can my script take care of this last issue?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Feng Lin</description>
      <pubDate>Tue, 04 Aug 2009 06:11:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466915#M360634</guid>
      <dc:creator>Fenglin</dc:creator>
      <dc:date>2009-08-04T06:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466916#M360635</link>
      <description>&amp;gt;For e.g, on 1st Jan 2010, the script won't be able to zip from the 16th Dec files to 31st Dec files.&lt;BR /&gt;&amp;gt;How can my script take care of this last issue?&lt;BR /&gt;&lt;BR /&gt;How does your script handle the previous month, if in the same year?&lt;BR /&gt;I assume you just check if Dec and subtract one from the year.&lt;BR /&gt;&lt;BR /&gt;Have you looked at Clay's caljd script to date arithmetic?&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1232368" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1232368&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1173224" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1173224&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1158441" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1158441&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1101623" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1101623&lt;/A&gt;</description>
      <pubDate>Tue, 04 Aug 2009 07:08:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-format/m-p/4466916#M360635</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-08-04T07:08:38Z</dc:date>
    </item>
  </channel>
</rss>

