Adding zeros

M

Matt

Office '03

I have a query that looks like this:
SELECT "09 - " & [Incident number] AS Incident, Format(Date(),"mm/dd/yy") AS
[Date], Incidents09.[sec assoc], Incidents09.Location, Incidents09.Area,
Incidents09.[Involved Parties], Incidents09.Classification,
Incidents09.[Description of Incident], Incidents09.[Incident Closed]
FROM Incidents09;

I am needing to now add zeros to those incident numbers that have less than
3 digits. (ie 09-1 to 09-001 and 09-50 to 09-050) How can I do this?

Thanks
 
J

John W. Vinson

I am needing to now add zeros to those incident numbers that have less than
3 digits. (ie 09-1 to 09-001 and 09-50 to 09-050) How can I do this?

Use the Format() function to turn the incident number into a formatted string:

SELECT "09 - " & Format([Incident number], "000") AS Incident,
Format(Date(),"mm/dd/yy") AS [Date], Incidents09.[sec assoc],
Incidents09.Location, Incidents09.Area,
Incidents09.[Involved Parties], Incidents09.Classification,
Incidents09.[Description of Incident], Incidents09.[Incident Closed]
FROM Incidents09;
 
M

Matt

Thanks John. I actually just figuired this out about 2 minutes after
posting. I should say after I receive a "service unavailable" error and
thought the posting failed. (I have been having this happen a lot lately.)

I see i'm not the only night owl :)

Thanks for your response.
--
73,
Matt


John W. Vinson said:
I am needing to now add zeros to those incident numbers that have less than
3 digits. (ie 09-1 to 09-001 and 09-50 to 09-050) How can I do this?

Use the Format() function to turn the incident number into a formatted string:

SELECT "09 - " & Format([Incident number], "000") AS Incident,
Format(Date(),"mm/dd/yy") AS [Date], Incidents09.[sec assoc],
Incidents09.Location, Incidents09.Area,
Incidents09.[Involved Parties], Incidents09.Classification,
Incidents09.[Description of Incident], Incidents09.[Incident Closed]
FROM Incidents09;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top