Length restriction to dynamic data

Is it possible to create a length restriction on a dynamic field to create an excerpt like the WP posts.
Length restriction if possible in words (max 20 words for example) or in char length.