I would recommend using the new Fluent Expressions for this kind of simple things. You do not require then to write an UDF.
Please Login to Report Topic
Please Login to Share Feed