Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I need a query that formats a set of numbers.

Posted on 2008-06-23
5
Medium Priority
?
203 Views
Last Modified: 2011-10-19
I just need an Access Query that changes the format of a set of numbers like this

08-01-   6-0059-0000-0000

into this

0801-0006-0059-0000-0000

Thank you
0
Comment
Question by:GravitaZ24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 21847900
If your first set of numbers is always in that format, then this should work for you:

NewFormat: Left([YourNumberField],2) & Mid([YourNumberField],4,2) & "-000" & Mid([YourNumberField],8,1) & "-" & Right([YourNumberField],14)

Flyster
0
 

Author Comment

by:GravitaZ24
ID: 21848710
I'm sorry that worked for the first few numbers, but there was more to it than I realized, I attached a sample of the numbers, I have to get them into this format xxxx-xxxx-xxxx-xxxx-xxxx-xxx. The second groups of numbers is where i'm having trouble, they have to be filled in with zeros where there are blanks.
0
 

Author Comment

by:GravitaZ24
ID: 21848716
I forgot to attach to the last post, here it is
Sample.xls
0
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 21849440
See if this works for you:

SELECT Sheet1.[Unique], Replace([Unique],"-","") AS Step1, Replace([Step1]," ",0) AS Step2, Format([Step2],"0000-0000-0000-0000-0000-000") AS Step3
FROM Sheet1;
0
 

Author Closing Comment

by:GravitaZ24
ID: 31469815
Thank you! that worked!
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question