Convert an ISO date into words

Convert an ISO date into words

Here is a demonstration of how one line of RPG free-form code can convert an International Standard Date and Time Notation (ISO) to words. This is a fairly complex statement; I don't normally recommend using the language in this manner. I made this exception as the formula is constant and therefore will not require deciphering in the future. The power and versatility of free code is demonstrated here. Pass the program an ISO date (example 1946-12-31) and it will return (Tuesday, December 31, 1946). I have been developing on IBM Midrange for 33 years and have seen RPG from the beginning. RPG Free-form is the latest and by far the most powerful and versatile form of RPG. I started using RPG Free-form about a year ago and do not intend on going back.
   
100      f*  Program ID        -  CDATE8G
02/09/05

    200      f*  Written By        -  James H. Greene

    300      f*  Date Written      -  2005/02/09
02/09/05

    400      f*  Purpose           -  return 30 character date in words

    500      f*                       example  Tuesday, December 31,
1946                                               02/09/05

    600      f*                       parm -isod- format 1946-12-31
02/09/05

    700
d*****************************************************************
02/09/05

    800      d isod            s               d   datfmt(*iso)
02/09/05

    900      d isodw           s               d   datfmt(*iso)
inz(d'0001-01-01')                                   

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts including news, tips, and advice to help you do your job more efficiently and effectively. Stay informed on the hottest topics and biggest challenges faced by IT professionals working with iSeries products and services.

    By submitting your registration information to Search400.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of Search400.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

02/09/05 1000 d word s 30a 02/08/05 1100 d days S 9 DIM(7) ctdata perrcd(7) 1200 d months S 9 DIM(12) ctdata perrcd(6) 1300 d***************************************************************** 02/09/05 1400 /free 02/08/05 1500 word = %trim(days(%rem(%diff(isod:isodw:*days):7) + 1)) + ', ' + 02/09/05 1600 %trim(months(%subdt(isod:*m))) + ' ' + 02/09/05 1700 %char(%subdt(isod:*d)) + ', ' + 02/09/05 1800 %char(%subdt(isod:*y)) ; 02/09/05 1900 *inlr = *on ; 02/09/05 2000 /end-free 02/08/05 2100 c************************************************ 02/09/05 2200 c *inzsr begsr 2300 c *entry plist 2400 c parm isod 02/09/05 2500 c parm word 02/08/05 2600 c endsr 2700 c************************************************ 02/09/05 2800 ** days of week 2900 Monday Tuesday Wednesday Thursday Friday Saturday Sunday 3000 ** months of year 3100 January February March April May June 3200 July August September October November December * * * * E N D O F S O U R C E * ** *

This was first published in March 2005

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.