0

I have a field in my table that contains numbers for instance: 7121968 - what I would like to do is add a . before the last four and before the last 6 digits so that it looks like: 7.12.1968. I can use substring to just show the last 4 digits etc - is what i am trying to do possible using substring and if so could someeone point me in the right direction? thanks.

2
  • Did you store a date there or are the numbers pure coincidence? Commented Nov 24, 2011 at 13:10
  • that was pure coincidence - should add i currently have substr(field, -4) Commented Nov 24, 2011 at 13:11

2 Answers 2

1
$x = '7121968';
$x2 = substr($x,0,-6) . '.' . substr($x,-6,2) . '.' . substr($x,-4);
Sign up to request clarification or add additional context in comments.

Comments

0

Do like this:

SELECT CONCAT(SUBSTRING(<column>, 1, 1), '.', SUBSTRING(<column>, 2, 2), '.', SUBSTRING(<column>, 4)) FROM <table>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.