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

Why won't Fns Trim, Truncate work? 1

Status
Not open for further replies.

misbrandy

MIS
Jun 12, 2007
41
US
I am using Crystal version 9. The functions Trim and Truncate do not work. I am using them in formulas. Values sent and returned still contain the '.00' at the end.

Any ideas why?

Here's what's happening:
I am trying to convert a year input by user (say 2007) to the proper format so I can determine which year of data to pull from the database. Crystal's conversion of 2007 to 2,007.00 became an issue in this case and many others. So I was trying to use trim and truncate to get rid of the '.00'.

I want to do something like this to pull all records from 1/1/year thru a named month of the same year:
{Table.Date} in
(DateValue({?Year},01, 01) to DateValue({?Year},{?Month},{@MonthDays}))




 
A display like 2,007.00 is a problem of display, it should compair OK as a date. You can also change the defaults using File > Options > Field.

For date selection, try
Code:
Year({Table.Date}) = {?Year}
and
{Table.Date} >= Date({?Year},{?Month},{@MonthDays})

If the selection seems to be failing, try removing it and putting it as a display beside the data, to see what's really there.


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thank you for your help. I realize my problem is a little more complex than I explained, but knowing
Year({Table.Date}) = {?Year}
works helped me look into this further.

What I am doing is calculating prior year ({?year} - 1) -- hence the need for conversion to numeric -- and that is getting me into trouble. I did figure out a way to do it, thou, using a truly roundabout method using left & mid to peel off the portions of 2,006.00 that make up 2006. Messy and seems very makeshift but for now it works.
 
Once you have a formula to get prior year as a number, convert it back to text without any decimals or punctuation:

ToText({YourNumberField},0,"")

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
OMG!!! I worked on this for hours!
Thanks so much.

I guess that brings up this: what is the best source for documentation on Crystal functions? I don't need in depth, just funtion, inputs & format, outputs & format. I get the functionality parts. My Crystal 'help' does not have many and even those in there seem to me to go on and on about nothing and in many cases does not actally say 'heres what goes in', 'heres how it comes out'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top