You 'll need some helper columns I think for this so that you understand what is going on.
I have a Surname Field
A data field called ExField
A current time field
Break it down into pieces so that you learn and understand how to get what you need.
Field UserName 2 - to show the first 2 letters of a surname - default value - substring(Surname, 1, 2)
Field TTime - to show the now () function with no spaces or T - translate(substring-after(now(), "T"), ":", "")
put it all together in another field ie RefNumber - concat(substring(Surname, 1, 3), ExtField, TTime)
I can't get the last letter of a surname (yet). Substring functions in InfoPath rely on you telling the forms how many characters are in a word. Obviously surnames are of different lengths. You could, if this is in SharePoint add a calculated column and it could give you the last letter using and excel function.