<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Dipti,</p>
    <p>Convert the year-month-day to a single calendar unit with <a
        moz-do-not-send="true"
href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_inv_calendar.shtml">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
        moz-do-not-send="true"
href="http://www.ncl.ucar.edu/Document/Functions/User_contributed/cd_string.shtml">cd_string</a>)
      or recover the year-month-day as separate variables using <a
        moz-do-not-send="true"
href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml">cd_calendar</a>:<br>
    </p>
    <p><tt>load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.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>
    <br>
    <div class="moz-cite-prefix">On 2018-05-23 02:44, Dipti Hingmire
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAGRW+JoAi9CX=GhwRs2Q1h6q7dHKzaFY4BbLo8e0iUikNn+A_Q@mail.gmail.com">
      <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="gmail_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="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
    </blockquote>
    <br>
  <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
        <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="" width="46" height="29" style="width: 46px; height: 29px;" /></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" target="_blank" style="color: #4453ea;">www.avast.com</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>