Announcement

Collapse
No announcement yet.

Help with %editw please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with %editw please

    Hi All:

    I have a date field defined as alpha (ND). It's value is 06132008. I want to insert the /'s so I used this code:
    Code:
         Start=%Editw(%Dec(Nd:8:0):'0 /  /    ');
    the result is ' 6/13/2008' I'm loosing the leading 0. I've tried to insert an extra space after the 0 in the edit word but that only shifts everything to the right ' /61/3200'.
    Does anyone know how to keep the leading 0?

    Thanks
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

  • #2
    Re: Help with %editw please

    OK........I've solved the issue with the following:
    Code:
         Start=%xlate(' ' : '0' :%Editw(%Dec(Nd:8:0):'0 /  /    '));
    Isn't there a better way?

    Thanks
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: Help with %editw please

      GLS,

      When I want leading zeros I usally use %EDITC( Field : 'X' ) but that's just me.

      HTH,
      MdnghtPgmr
      "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

      Comment


      • #4
        Re: Help with %editw please

        Alpha = %Editw(ND: '0bb/bb/bbbb') b= blanks

        My resulting field was defined as 10 characters.
        Last edited by Billw; May 28, 2008, 12:09 PM.
        Bill
        "A good friend will bail you out of jail,
        A true friend would be sitting beside you saying,
        'Wow, that was fun.'"

        Comment


        • #5
          Re: Help with %editw please

          Think you could try
          Start=%Editw(%Dec(Nd:9:0):' 0 / / ');
          Regards

          Kit
          http://www.ecofitonline.com
          DeskfIT - ChangefIT - XrefIT
          ___________________________________
          There are only 3 kinds of people -
          Those that can count and those that can't.

          Comment


          • #6
            Re: Help with %editw please

            Gentlemen:

            Bill: I tried that result was ' /61/3200'

            MdnghtPgmr: how do i get my / inserted?

            kitvb1: doesn't compile:

            *RNF8004 20 000700 The edit word has 8 replaceable chacters but 9 are needed.

            Thanks
            GLS
            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

            Comment


            • #7
              Re: Help with %editw please

              GLS,

              I do stuff like

              Code:
              MonthEndDate = %DATE(
                                     %EDITC( IssueMM : 'X' ) + '/' +
                                     %EDITC( IssueDD : 'X' ) + '/' +
                                     %EDITC( IssueCY : 'X' ) 
                                                );
              Not exactly pretty but it does the job.

              HTH,
              MdnghtPgmr
              "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

              Comment


              • #8
                Re: Help with %editw please

                Code:
                Start = %Char(%Date(nd:*USA):*USA);
                ?
                Last edited by tomholden; May 28, 2008, 12:48 PM.
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: Help with %editw please

                  I think Tom's got the best solution. However your original should work, but "Start" needs to be 9 positions.

                  Start=%Editw(%Dec(Nd:8:0):'0bb/bb/bbbb');

                  Comment


                  • #10
                    Re: Help with %editw please

                    *DING *DING *DING

                    We have a few winners here folks.
                    Tom was probably the best as
                    Start = %Char(%Date(nd:*USA0):*USA);
                    needed the *USA0 instead of *usa for the date conversion
                    Arrow and Bill both with the extra space in the edit word
                    start needed to be 11

                    Thanks to All who helped
                    GLS
                    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                    Comment


                    • #11
                      Re: Help with %editw please

                      Originally posted by GLS400 View Post
                      *DING *DING *DING

                      We have a few winners here folks.
                      Tom was probably the best as
                      Start = %Char(%Date(nd:*USA0):*USA);
                      needed the *USA0 instead of *usa for the date conversion
                      Arrow and Bill both with the extra space in the edit word
                      start needed to be 11

                      Thanks to All who helped
                      GLS
                      You only need *USA0 if the nd field is character. If the field was numeric then the *USA would work.

                      The previous edit words use the 11 characters to ensure you get the two digits in the month.

                      I would go with the %CHAR(%DATE() :*USA);

                      But if you wanted to use the edit word you would need to trim the leading blank. Alternatively you could use an EVALR opcode which would fill the character field from the right side instead of left.
                      Code:
                      /FREE
                        EVALR CHAR10FLD = %CHAR(%DATE( Numeric8 :*USA): *USA);
                      
                        CHAR10FLD = %TRIM( %Editw(ND: '0bb/bb/bbbb') );
                      
                         //b= blanks
                      /END-FREE
                      The advantage of using the %date method is that you can easily convert to other formats.
                      Code:
                      /FREE
                        Numeric8usa = %DEC (%DATE( Numeric8iso :*ISO) :*USA);
                      
                        Char10usa = %CHAR( %DATE( Numeric8ISO :*ISO) :*USA);
                      
                      /END-FREE
                      Note that %DEC( %DATE() :*usa) is V5R4 enhancement.

                      Comment


                      • #12
                        Re: Help with %editw please

                        Thanks Chris .......Greatly Appreciated

                        GLS
                        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                        Comment

                        Working...
                        X