<div dir="ltr"><div>Thanks Walter. It worked.<br><br><br></div><br><div><div class="gmail-m_-1713055631898945418gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Thanks and Regards,</div><div>Dipti</div></div></div></div></div></div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Thanks and Regards,</div><div>Dipti</div><div><br></div></div></div></div></div></div></div>
<br><div class="gmail_quote">2018-05-23 12:46 GMT+05:30 Walter Kolczynski <span dir="ltr"><<a href="mailto:walter.kolczynski@noaa.gov" target="_blank">walter.kolczynski@noaa.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>Dipti,</p>
    <p>Convert the year-month-day to a single calendar unit with <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_inv_calendar.shtml" target="_blank">cd_inv_calendar</a>
      (I usually use Unix epoch-seconds, but NCL is flexible), do the
      math in that space, and then use that to make a string (using <a href="http://www.ncl.ucar.edu/Document/Functions/User_contributed/cd_string.shtml" target="_blank">cd_string</a>)
      or recover the year-month-day as separate variables using <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml" target="_blank">cd_calendar</a>:<br>
    </p>
    <p><tt>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/contrib/cd_string.<wbr>ncl"<br>
        <br>
        start_year    = 2018<br>
        start_month   = 1<br>
        start_day     = 5<br>
        delta_days    = -7<br>
        <br>
        start_time    = cd_inv_calendar( start_year, start_month,
        start_day, 0, 0, 0, "seconds since 1970-1-1 00:00:00", 0 )<br>
        delta         = delta_days * 86400             ; Convert delta
        to seconds, since our calendar units are seconds<br>
        end_time      = start_time + delta<br>
        copy_VarAtts(start_time, end_time)             ; Copy calendar information
        to end_time<br>
        end_string    = cd_string(end_time, "%Y-%N-%D")<br>
        end_time_UT   = cd_calendar(end_time, -5)      ; -5 gives
        integer values instead of float<br>
        end_year      = end_time_UT(:,0)<br>
        end_month     = end_time_UT(:,1)<br>
        end_day       = end_time_UT(:,2)<br>
        <br>
        print(end_string)<br>
        print(end_year)<br>
        print(end_month)<br>
        print(end_day)</tt></p>
    <p><tt>**** OUTPUT ****<br>
      </tt></p>
    <p><tt>Variable: end_string<br>
        Type: string<br>
        Total Size: 8 bytes<br>
                    1 values<br>
        Number of Dimensions: 1<br>
        Dimensions and sizes:   [1]<br>
        Coordinates: <br>
        Number Of Attributes: 1<br>
          _FillValue :  missing<br>
        (0)     2017-12-29<br>
        <br>
        Variable: end_year<br>
        Type: integer<br>
        Total Size: 4 bytes<br>
                    1 values<br>
        Number of Dimensions: 1<br>
        Dimensions and sizes:   [1]<br>
        Coordinates: <br>
        Number Of Attributes: 1<br>
          calendar :    standard<br>
        (0)     2017<br>
        <br>
        Variable: end_month<br>
        Type: integer<br>
        Total Size: 4 bytes<br>
                    1 values<br>
        Number of Dimensions: 1<br>
        Dimensions and sizes:   [1]<br>
        Coordinates: <br>
        Number Of Attributes: 1<br>
          calendar :    standard<br>
        (0)     12<br>
        <br>
        Variable: end_day<br>
        Type: integer<br>
        Total Size: 4 bytes<br>
                    1 values<br>
        Number of Dimensions: 1<br>
        Dimensions and sizes:   [1]<br>
        Coordinates: <br>
        Number Of Attributes: 1<br>
          calendar :    standard<br>
        (0)     29<br>
        <br>
      </tt>- Walter<br>
    </p><div><div class="h5">
    <br>
    <div class="m_-5719813883415627176moz-cite-prefix">On 2018-05-23 02:44, Dipti Hingmire
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">
        <div>
          <div>
            <div>Dear All,<br>
              <br>
            </div>
            I wan to plot lead lag composite plots of a set of
            events/dates.<br>
            <br>
          </div>
          Is there any inbuilt function in ncl which will provide me
          date after/before specified number of days of given date?<br>
          <br>
          <br>
        </div>
        e.g. If i give 2018-01-05 as input date and I want the date 7
        days before I should get 2017-12-29<br>
        <div>
          <div>
            <div>
              <div><br clear="all">
                <div>
                  <div class="m_-5719813883415627176gmail_signature">
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">
                          <div dir="ltr">
                            <div>Thanks and Regards,</div>
                            <div>Dipti</div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="m_-5719813883415627176mimeAttachmentHeader"></fieldset>
      <br>
      </div></div><pre>______________________________<wbr>_________________
ncl-talk mailing list
<a class="m_-5719813883415627176moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="m_-5719813883415627176moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a>
</pre>
    </blockquote>
    <br>
  <div id="m_-5719813883415627176DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tbody><tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=icon" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" style="width:46px;height:29px" height="29" width="46"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=link" style="color:#4453ea" target="_blank">www.avast.com</a>
                </td>
        </tr>
</tbody></table><a href="#m_-5719813883415627176_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></div>

<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>