<div dir="ltr"><div>No function .... just straight forward programming. You can create a function if you want.<br></div><div><br></div><div> month = (/"jan","feb","mar","apr","may","jun" \<br>          ,"jul","aug","sep","oct","nov","dec"/)<br><br> yyyymmdd = 20090402<br><br> yyyy    = yyyymmdd/10000<br> mmdd = yyyymmdd-(yyyy*10000)<br> mm     = mmdd/100<br> dd       = mmdd-(mm*100)<br> print("yyyy="+yyyy+": mm="+mm+": dd="+dd)<br><br> DATE = sprinti("%0.2i", mm) + month(mm-1) + yyyy<br> print(DATE)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 19, 2020 at 8:31 AM Rick Brownrigg via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I think you want cd_string, not cd_convert:</div><div><br></div><div>    <a href="http://ncl.ucar.edu/Document/Functions/User_contributed/cd_string.shtml" target="_blank">http://ncl.ucar.edu/Document/Functions/User_contributed/cd_string.shtml</a></div><div><br></div><div>From those docs, I'm not sure it will give days as "2nd", "3rd"..."31st", etc, but it will certain give 2, or 02, etc. </div><div><br></div><div>It looks like cd_convert is used to convert various linear time units, ex, "days from..." to "months from...", etc.</div><div><br></div><div>Rick<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 19, 2020 at 3:46 AM Geeta Geeta via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi <br>
in my code, I have extracted the dats which looks like 20090402 (2nd April2009).I have to convert it to the format 02apr2009. <br>
<br>
I am using cd_convert to write the date and time in the required format. <br>
<br>
Following is the lines from the code.  I have added units  to this variable YYMMDD<br>
<br>
YYMMDD           =   stringtointeger(Split_name(1))            ; string variable<br>
<br>
                    print(YYMMDD)<br>
   YYMMDD@units     = "days since 0000-01-01 00:00:0.0"<br>
;                      printVarSummary(YYMMDD)<br>
<br>
    stime            =  cd_convert(YYMMDD,"%c%y")<br>
;                       print(stime)<br>
<br>
<br>
I get error like this<br>
CDMS error: Error on relative units conversion: invalid units = %c%y<br>
<br>
kindly suggest<br>
<br>
<br>
Geeta.<br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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/mailman/listinfo/ncl-talk</a></blockquote></div>