<?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 with problem for getting dates in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078774#M94969</link>
    <description>What's weird?  20071001 - 1 = 20071000, and&lt;BR /&gt;20071001 - 1 - 6 = 20070994.  You got what&lt;BR /&gt;you asked for.&lt;BR /&gt;&lt;BR /&gt;The result of "date '+%Y%m%d'" is not an&lt;BR /&gt;ordinary decimal number, so you can't do&lt;BR /&gt;ordinary decimal arithmetic on it and get&lt;BR /&gt;a resonable answer, except by luck.&lt;BR /&gt;&lt;BR /&gt;You might look at the suggestions for a&lt;BR /&gt;similar problem at:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1040167" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1040167&lt;/A&gt;</description>
    <pubDate>Mon, 01 Oct 2007 00:57:43 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2007-10-01T00:57:43Z</dc:date>
    <item>
      <title>Script with problem for getting dates</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078773#M94968</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Today is Oct-1-2007, a Monday date. My script runs werid that is to start with getting the last Sunday date, then the Monday date before this Sunday date.&lt;BR /&gt; &lt;BR /&gt;day1=`date "+%Y%m%d"`&lt;BR /&gt;day2=`date +%w`&lt;BR /&gt;if [ $day2 -eq 0 ]; then&lt;BR /&gt;   sun_day=$day1&lt;BR /&gt;else&lt;BR /&gt;   sun_day=`date +%Y%m%d-$day2|bc`&lt;BR /&gt;fi&lt;BR /&gt;mon_day=`date +%Y%m%d-$day2-6|bc`&lt;BR /&gt;echo $sun_day $mon_day&lt;BR /&gt;&lt;BR /&gt;The result produced is:&lt;BR /&gt;&lt;BR /&gt;20071000 20070994&lt;BR /&gt;&lt;BR /&gt;Pls render help&lt;BR /&gt;&lt;BR /&gt;Rita</description>
      <pubDate>Sun, 30 Sep 2007 22:36:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078773#M94968</guid>
      <dc:creator>Rita Li</dc:creator>
      <dc:date>2007-09-30T22:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Script with problem for getting dates</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078774#M94969</link>
      <description>What's weird?  20071001 - 1 = 20071000, and&lt;BR /&gt;20071001 - 1 - 6 = 20070994.  You got what&lt;BR /&gt;you asked for.&lt;BR /&gt;&lt;BR /&gt;The result of "date '+%Y%m%d'" is not an&lt;BR /&gt;ordinary decimal number, so you can't do&lt;BR /&gt;ordinary decimal arithmetic on it and get&lt;BR /&gt;a resonable answer, except by luck.&lt;BR /&gt;&lt;BR /&gt;You might look at the suggestions for a&lt;BR /&gt;similar problem at:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1040167" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1040167&lt;/A&gt;</description>
      <pubDate>Mon, 01 Oct 2007 00:57:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078774#M94969</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-10-01T00:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Script with problem for getting dates</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078775#M94970</link>
      <description>&lt;!--!*#--&gt;Hello Rita,&lt;BR /&gt;&lt;BR /&gt;date '+%m %d %Y' |&lt;BR /&gt;{&lt;BR /&gt;read MONTH DAY YEAR&lt;BR /&gt;DAY=`expr "$DAY" - 1`&lt;BR /&gt;case "$DAY" in&lt;BR /&gt;        0)&lt;BR /&gt;           MONTH=`expr "$MONTH" - 1`&lt;BR /&gt;                case "$MONTH" in&lt;BR /&gt;                        0)&lt;BR /&gt;                           MONTH=12&lt;BR /&gt;                           YEAR=`expr "$YEAR" - 1`&lt;BR /&gt;                        ;;&lt;BR /&gt;                esac&lt;BR /&gt;        DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`&lt;BR /&gt;esac&lt;BR /&gt;sun_day=$YEAR/$MONTH/$DAY&lt;BR /&gt;mon_day=`date +%Y/%m/%d`&lt;BR /&gt;echo $sun_day $mon_day&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The result produced is:&lt;BR /&gt;&lt;BR /&gt;2007/9/30 2007/10/01&lt;BR /&gt;&lt;BR /&gt;Please modify above script further.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 01 Oct 2007 01:49:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078775#M94970</guid>
      <dc:creator>TY 007</dc:creator>
      <dc:date>2007-10-01T01:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Script with problem for getting dates</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078776#M94971</link>
      <description>A. Clay's script is great&lt;BR /&gt;&lt;BR /&gt;Problem is fixed&lt;BR /&gt;&lt;BR /&gt;Thank you for the prompt respond&lt;BR /&gt;&lt;BR /&gt;Rita</description>
      <pubDate>Mon, 01 Oct 2007 12:15:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-with-problem-for-getting-dates/m-p/4078776#M94971</guid>
      <dc:creator>Rita Li</dc:creator>
      <dc:date>2007-10-01T12:15:07Z</dc:date>
    </item>
  </channel>
</rss>

