Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal 7.0 - Formatting return data 1

Status
Not open for further replies.

cruford

Programmer
Dec 6, 2002
138
US
I am converting an Access 2000 database to SQL / VB. I am new to SQL and Crystal so forgive me if this is an easy question. All my searches here didn't turn up what I was looking for.

My SQL database stores phone numbers as 1234567890. I would like them displayed as (123)456-7890 on my crystal reports. Do I need to do this in my Stored Proc? If so how do I select a field and format it on the fly?

Example

********Stored Proc***************
CREATE PROCEDURE sp_Information
@CustID INT
AS
SELECT *
FROM
viewPatientInformation
WHERE
CustID = @CustID
GO

********Views***************

SELECT (whole lot of fields), PhoneNumber FROM ztblSomeTable


How do I get the PhoneNumber field displayed with formatting?
 
In CR, you could create a formula:

picture({table.phonestring},"(xxx) xxx-xxxx")

This assumes that {table.phone} is a string. If it is a number, change the formula to:

picture(totext({table.phonenumber},0,""),"(xxx) xxx-xxxx")

I added in a space between the area code and the number, although you didn't have one--delete it if you really don't want it.

-LB
 
Oops, just realized you probably don't have the picture function in 7.0. Not sure what functions are available to you. If you can use the "left" and "mid" functions, you could do:

"(" + left({table.phonestring},3) + ") " + mid({table.phonestring},4,3) +
"-" + mid({table.phonestring},7)

-LB
 
Our internet is pretty much locked down so I can get the file. I will look into the formulas, thanks for the syntax. I will post what I come up with. Thanks for the help.
 
Thanks lbass the suggestion below works great:

"(" + left({table.phonestring},3) + ") " + mid({table.phonestring},4,3) +
"-" + mid({table.phonestring},7)

Here's a star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top