简体   繁体   中英

How to change field into SSN format (###-##-####) in MS Access?

I know how to edit a field to remove the dashes but how do I take a field that is a text field with 9 numbers and manipulate it so that it follows standard SSN formatting? Open to VBA or Query (SQL) methods. Thank you in advance!

There is Format(expression[, format[, firstdayofweek[, firstweekofyear]]]) function, which can show you your 9 symbols in desired format

?format("123456789","@@@-@@-@@@@")
123-45-6789

If you decided to change stored values you can use SQL query like this

UPDATE [tblTable] SET [ssn] = format([ssn],"@@@-@@-@@@@")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM