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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formating formula 1

Status
Not open for further replies.

TMRO

Technical User
Jan 10, 2003
140
0
0
CA
Hi,

I have a formula with this underlying code:

if isnull({sp_not_expired.QTY}) then
formula = ""
else
formula = CStr({sp_not_expired.QTY})
end if

where sp_not_expired is a stored procedure and QTY a numeric field, which I don't want to display if it's null. Now when I display the results in CR it shows the number with 2 decimals. How can I take the decimals out?

Thank you
 
This should do it

if isnull({sp_not_expired.QTY}) then
formula = ""
else
formula = CStr({sp_not_expired.QTY},0)
end

Gary Parker
MIS Data Analyst
Manchester, England
 
How about dates? How do you format the date?

if isnull({sp_not_expired.DateExp}) then
formula = ""
else
formula = CStr({sp_not_expired.DateExp})
end if

Thanks a lot. The number formating worked fine.
 
It woudl depend on the how you would like the date formatting, this is all documented in the help for the CStr or ToText functions

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
I don't need the minutes and seconds to be shown. Could you give me an example, I don't have the help for Crystal.

Thank you
 
if isnull({sp_not_expired.DateExp}) then
formula = ""
else
formula = CStr({sp_not_expired.DateExp},"dd/MM/yyyy")
end if

or any combination of these characters

Code:
Character Comments 
d
 day of month without leading zero for single digits
 
dd
 day of month with leading zero for single digits.
 
ddd
 day of week as a three letter abbreviation
 
dddd
 full name of day of week
 
M
 month without leading zero for single digit
 
MM
 month with leading zero for single digit
 
MMM
 month as three letter abbreviation.
 
MMMM
 full name of month
 
yy
 last two digits of year
 
yyyy
 full four digits of year
 
h
 hours without leading zeros for single digits (12 hour)
 
hh
 hours without leading zeros for single digits (12 hour).
 
H
 hours without leading zeros for single digits (24 hour)
 
HH
 hours with leading zeros for single digits (24 hour)
 
m
 minutes without leading zeros for single digits
 
mm
 minutes with leading zeros for single digits
 
s
 seconds without leading zeros for single digits
 
ss
 seconds with leading zeros for single digits
 
t, tt
 single character or multiple character a.m./p.m. string




Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top