Solved

I need a query that formats a set of numbers.

Posted on 2008-06-23
5
200 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
  • 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 125 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 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