<?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: Playing with date.. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094836#M92399</link>
    <description>&lt;!--!*#--&gt;&amp;gt;NKG: Find the attached solution.&lt;BR /&gt;&lt;BR /&gt;To go back more than one day, get_one_day_before_specified_date must be called N times.&lt;BR /&gt;Some slight improvements can be made:&lt;BR /&gt;   if [ $intmonth -eq 01 ]; then&lt;BR /&gt;      intmonth=12&lt;BR /&gt;Not needed since checked in "then" block.&lt;BR /&gt;&lt;BR /&gt;   intmonth=`expr $intmonth - 1`&lt;BR /&gt;Can be done with: (( intmonth -= 1 ))&lt;BR /&gt;&lt;BR /&gt;   ${AWK} 'NF != 0{ last = $0 }; END{ print last }' |  ${AWK} '{ print $NF }'&lt;BR /&gt;Can be done with one awk:&lt;BR /&gt;   ${AWK} 'NF != 0 { last = $NF }; END{ print last }'</description>
    <pubDate>Tue, 06 Nov 2007 03:08:07 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-11-06T03:08:07Z</dc:date>
    <item>
      <title>Playing with date..</title>
      <link>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094832#M92395</link>
      <description>Hi Experts,&lt;BR /&gt;   I have some requirements with date. Based on TODAY and YESTERDAY, need to calculate the date variables. Which will be passed as an argument to the database.&lt;BR /&gt;&lt;BR /&gt;If today is Thursday Oct 25, 2007:&lt;BR /&gt;&lt;BR /&gt;Requirements.&lt;BR /&gt;Value     Maestro parm and meaning&lt;BR /&gt;&lt;BR /&gt;TODAY = today ( today's date )&lt;BR /&gt;YESTERDAY = Yesterday .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$YESTERDAY &amp;lt; 1 DAY = day before yesterday&lt;BR /&gt;$YESTERDAY &amp;lt; 2 days = 2 days before yesterday (3 days ago)&lt;BR /&gt;$YESTERDAY &amp;lt; 6 DAYS = 6 days before yesterday&lt;BR /&gt;$YESTERDAY &amp;lt; 7 DAYS = 7 days before yesterday&lt;BR /&gt;$YESTERDAY &amp;lt; 20 DAYS = 20 days before yesterday&lt;BR /&gt;$YESTERDAY &amp;lt; 30 DAYS = 30 days before yesterday&lt;BR /&gt;$YESTERDAY &amp;lt; 60 DAYS = 60 days before yesterday&lt;BR /&gt;$YESTERDAY &amp;lt; 90 DAYS = 90 days before yesterday&lt;BR /&gt;$YESTERDAY &amp;lt; NEAREST FIRSTDAY = the nearest first day of month before yesterday&lt;BR /&gt;$TODAY &amp;lt; 1 MONTH &amp;lt; NEAREST FIRSTDAY = the nearest first day of the month before 1 month ago&lt;BR /&gt;$YESTERDAY &amp;lt; 6 MONTH &amp;lt; NEAREST FIRSTDAY = the nearest first day of the month before 6 months ago&lt;BR /&gt;$YESTERDAY &amp;lt; 12 MONTH &amp;lt; NEAREST FIRSTDAY = the nearest first day of the month before 1 year ago&lt;BR /&gt;$YESTERDAY &amp;lt; 24 MONTH &amp;lt; NEAREST FIRSTDAY = the nearest first day of the month before 2 years ago&lt;BR /&gt;$TODAY &amp;lt; NEAREST LASTDAY = the nearest last day of the month before today&lt;BR /&gt;$TODAY &amp;lt; 1 MONTH &amp;lt; NEAREST LASTDAY = the nearest last day of the month before 1 month ago&lt;BR /&gt;$TODAY &amp;lt; 1 MONTH &amp;gt; NEAREST LASTDAY = the nearest last day of the month after 1 month ago&lt;BR /&gt;$YESTERDAY &amp;gt; 14 DAYS = 14 days forward from yesterday&lt;BR /&gt;&lt;BR /&gt;Is there any better way to write a script or function to archive this.</description>
      <pubDate>Wed, 31 Oct 2007 02:32:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094832#M92395</guid>
      <dc:creator>Sridhara</dc:creator>
      <dc:date>2007-10-31T02:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with date..</title>
      <link>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094833#M92396</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Use Perl;&lt;BR /&gt;&lt;BR /&gt;To obtain dates in the past or the future, you can simply do:&lt;BR /&gt;&lt;BR /&gt;# perl -MPOSIX -le '$days=shift or die;print strftime "%m/%d/%Y",localtime(time-$days*86400)' 1&lt;BR /&gt;&lt;BR /&gt;10/30/2007&lt;BR /&gt;&lt;BR /&gt;...or yesterday (one day ago).&lt;BR /&gt;&lt;BR /&gt;The 'strftime' formatting directives can be found in the standard manpages so you can craft your output according to your taste.&lt;BR /&gt;&lt;BR /&gt;The above code can also be made to calculate future dates:&lt;BR /&gt;&lt;BR /&gt;# perl -MPOSIX -le '$days=shift or die;print strftime "%m/%d/%Y",localtime(time-$days*86400)' -- -1&lt;BR /&gt;&lt;BR /&gt;11/01/2007&lt;BR /&gt;&lt;BR /&gt;THe double dash says that no options follow and thus the '-1' is treated as the argument we want.&lt;BR /&gt;&lt;BR /&gt;You will find the Perl 'Date::Calc' module quite useful for more complicated calculations.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;&lt;BR /&gt;Pass the</description>
      <pubDate>Wed, 31 Oct 2007 06:49:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094833#M92396</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-31T06:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with date..</title>
      <link>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094834#M92397</link>
      <description>Check out  (google) the caljd tool (shell or perl) often referred to in this forum. It can do many (all?) of the above request, but uses a different 'language'.&lt;BR /&gt;Is the above specification a fixed given, or can you use something caljd uses?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If i were to have to solve a problem like stated i would grab PERL and check out Time::Timelocal and localtime (sp) between them you can create and work with an array of time elements (month-day, month).&lt;BR /&gt;That make it easy to calculate the time corresponding with the first of the month, the firs of last month and so on.  Switch to the time in seconds to subtrace days (24*60*60 = 86400 seconds / day)&lt;BR /&gt;&lt;BR /&gt;It's work, but not unpleasant.&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 31 Oct 2007 06:51:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094834#M92397</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-31T06:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with date..</title>
      <link>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094835#M92398</link>
      <description>Hello Sridhara,&lt;BR /&gt;&lt;BR /&gt;Find the attached solution.&lt;BR /&gt;&lt;BR /&gt;Rgds&lt;BR /&gt;-NKG-</description>
      <pubDate>Tue, 06 Nov 2007 02:46:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094835#M92398</guid>
      <dc:creator>Nitin Kumar Gupta</dc:creator>
      <dc:date>2007-11-06T02:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with date..</title>
      <link>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094836#M92399</link>
      <description>&lt;!--!*#--&gt;&amp;gt;NKG: Find the attached solution.&lt;BR /&gt;&lt;BR /&gt;To go back more than one day, get_one_day_before_specified_date must be called N times.&lt;BR /&gt;Some slight improvements can be made:&lt;BR /&gt;   if [ $intmonth -eq 01 ]; then&lt;BR /&gt;      intmonth=12&lt;BR /&gt;Not needed since checked in "then" block.&lt;BR /&gt;&lt;BR /&gt;   intmonth=`expr $intmonth - 1`&lt;BR /&gt;Can be done with: (( intmonth -= 1 ))&lt;BR /&gt;&lt;BR /&gt;   ${AWK} 'NF != 0{ last = $0 }; END{ print last }' |  ${AWK} '{ print $NF }'&lt;BR /&gt;Can be done with one awk:&lt;BR /&gt;   ${AWK} 'NF != 0 { last = $NF }; END{ print last }'</description>
      <pubDate>Tue, 06 Nov 2007 03:08:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094836#M92399</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-11-06T03:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Playing with date..</title>
      <link>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094837#M92400</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;If you have found a solution, please assign points and close this thread.  Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 08 Nov 2007 07:26:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/playing-with-date/m-p/4094837#M92400</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-11-08T07:26:32Z</dc:date>
    </item>
  </channel>
</rss>

