Trim Datafields

Last post 11-06-2009 8:20 AM by TATWORTH. 1 replies.

Sort Posts:

  • Trim Datafields

    11-05-2009, 10:51 AM
    • Member
      4 point Member
    • tous0024
    • Member since 09-20-2009, 10:15 PM
    • Posts 63

    Group, I am building my first Crystal Report and I have 3 fields (City, State, Zip) and they are inline.  I would like to trim each field so they exclude additional spaces depending on the length of the field and also separate them by a comma.  Currently the length of the field is determined by the textbox length so for example you have Tulsa          ,  AZ       , 00000       Instead of Tulsa, AZ, 00000

    Anyway to set a field to rtrim?

    Any help is greatly appreciated.

  • Re: Trim Datafields

    11-06-2009, 8:20 AM
    • All-Star
      62,811 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 8:34 AM
    • England
    • Posts 12,256
    • TrustedFriends-MVPs

    Assuming that your back-end database is SQL Server, write a function that takes three arguments and returns a varchar.

    You can LTRIM(RTRIM(field)) for each field and combine as in:

    RETURN LTRIM(RTRIM(City)) + ', ' + LTRIM(RTRIM(State)) + ', ' + LTRIM(RTRIM(Zip))

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
Page 1 of 1 (2 items)