Remove all characters after first white space in SSRS 2005

限于喜欢 提交于 2019-12-11 06:24:46

问题


in an SSRS report textbox, i have this =Fields!FullName.Value which displays a customers Full name (FirstName and LastName). What i want to do is to only display their FirstName. I basically want to to remove every character that comes after the first white space

E.G if the value returned is Tom Ndovu, i want to Dispaly Tom.

if its Bill M Chark, i want to only display Bill.


回答1:


This instruction get the string from the start to the first occurence the character " " (space)

=Mid(Fields!FullName.Value,1, Instr(Fields!FullName.Value, " "))

If the white space is not always present you should check the value returned from Instr using something like this

=Mid(Fields!FullName.Value ,1,
IIF(Instr(Fields!FullName.Value, " ") > 0 ,Instr(Fields!FullName.Value, " "),
LEN(Fields!FullName.Value)))


来源:https://stackoverflow.com/questions/5819335/remove-all-characters-after-first-white-space-in-ssrs-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!