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

Custom formatted data fields 1

Status
Not open for further replies.

adiMasher

Programmer
Aug 31, 2001
144
US
Okay,

I'm a novice to crystal reports but I think I may know enough to get me started.

I'm using Goldmine as the SQL DB... in it, they store times in the HH:MM:SS format rather than saying 2.5 hours

I've got to the point of the report wizard where it wants to calculate totals. but because of the format of the field it doesn't do it automatically, it only picks the high water mark.

I'm thinking I'll have to add some code in there to make it recognize the format and then to sum it all up.

What code will I need, where do I put it and all that jazz.

If you know of a resource in particular that I can learn from, I would also be willing to learn of it as well.

Martin

If the sky is blue and the Sun is yellow.... Why isn't the air Green?
 
The version of software you're inquiring about is generally basic required information.

For CR 9 and above, you would right click Formula Fields in the field explorer and select New

Place something like:

time({table.timefield})

This assumes that it's a string value in the format you specified.

Are you intending to then sum a time? That's a bit tricky...

Rather that stating general thoughts, try posting specifics:

Crystal version
Database/connectivity used
Example data
Expected Output

-k
 
Okay, I'm going to start this up again,
because I'm not able to get this to work
I'm using Crystal reports 8.5

I want to run a total off of a field that in SQL is stored as a string, each row has an item that is formatted with HH:MM:SS but it isn't the time of day but the amount of time

how do I get the report to add up the amount of time and display it in the report?

Thanks,
Martin

If the sky is blue and the Sun is yellow.... Why isn't the air Green?
 
You could try to convert the 'Time' field to seconds, then sum up the seconds, and create a formula to spit out the results in HH:MM:SS form (or whatever format you want).

The formula to convert your Time string field would be:

DateTimeToSeconds (datetime(date(1900,1,1),CTime({Table.Field)));

You should be able to create a summary off of the formula, since the result is a number. See faq767-3543 for a method to display the resulting summary in HH:MM:SS format.

-dave
 
That worked beautifully!!!!! all I had to do was divide by 3600 to give me the decimal hour and I was set!

Thanks

If the sky is blue and the Sun is yellow.... Why isn't the air Green?
 
As for the air not being green, in fact the air is blue. That is to say, it scatters blue light better than other colours, so we see it as blue during the day, hence distant mountains looking blue. This also makes the sun look yellower than it really is, as well as looking red on the horizon, when there's a lot of air to pass through.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top