× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



 Is this right, or is there a flaw somewhere?

Char10 = %Subst(%Char(Date8):5:2)  +  '/'  +
              %Subst(%Char(Date8):7:2)  +  '/'  +
              %Subst(%Char(Date8):1:4)

The problem is that %CHAR() doesn't simply convert a number to a character field. It also formats it so that it's nicely read by human beings. So if you have a 7,2 field containing '0012345' then %char() will format it as '123.45' It removes the leading zeroes, and adds the decimal place to make it look nice to the user.

Unfortunately, the fact that it's formatted nicely is messing you up. When Date8 = 00000000, %char() will format it to simply be '0'. Note that '0' is only one character long. You can't take a substring starting in position 5, because there's only 1 position to begin with!

If you decide to continue doing it this way, consider using %EDITC(Date8:'X') instead of %CHAR(Date8). the X edit code does exactly what you want -- it retains the length of the field, and leaves the leading zeroes intact.

However -- why not use date operations?  You can do this quite easily:

     test(de) Date8;
     if %error;
         Char10 = *blanks;
     else;
         Char10 = %char( %date(Date8:*ISO) :  *USA/ );
     endif;

Or if you prefer:

     monitor;
         Char10 = %char( %date(Date8:*ISO) :  *USA/ );
     on-error;
         Char10 = *blanks;
     endmon;


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.