Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a dash before last 2 #'s in an account number

Status
Not open for further replies.

ITALIAORIANA

Technical User
Apr 22, 2005
103
US
Hello,

I am trying to add a "-" before the last two digits of an account number. I was trying to use Right([account],2)&"-" but this keeps putting the "-" after the last two digits. The accoutn numbers vary in digits but the last two digits are always the occupant number. Can anyone tell me if there is a formula to do this?

thanks
Deana
 
You may be in the wrong forum - this is for general database discussion. Are you using one of the SQLs or Access? You will generally get more appropriate answers in the correct forum.

If it's Access then just use standard functions and string concatenation:
Code:
SELECT Left$([Account],(Len([Account])-2))  & "-" & Right$([Account],2) AS Expr1
FROM myTable;

If it's MySQL look up the Concat function

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks johnwm that worked perfectly. I am using access, thanks for the answer and the heads up about remembering to put the system I am using.

Deana
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top