Print Page | Close Window

Change time from number to regular time

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1973
Printed Date: 26 Apr 2024 at 2:04pm


Topic: Change time from number to regular time
Posted By: irietek
Subject: Change time from number to regular time
Date Posted: 03 Jan 2008 at 11:09am
Hello, in my crystal report it is pulling the time in a format like:
94.85

I would like to change it to regular hours and minutes, it should be 95.25

How can I accomplish this?

Thank you,

DC



Replies:
Posted By: Lugh
Date Posted: 03 Jan 2008 at 11:38am
Ah, I probably should have titled my post better.  Check out http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1935 - this post from a few days ago.  It's about using an obscure financial function, DollarFR, to do this conversion surprisingly easily.  I would be very interested in feedback as to how it worked, as I haven't really tried it yet.




Posted By: irietek
Date Posted: 03 Jan 2008 at 12:16pm
Hello,

that was a speedy response =)

But I don't think this will work for me.


94.85 should = 95.25
3.50 should = 3.50
5.61 should = 6.01
4.59 should = 4.59

etc etc



Posted By: Lugh
Date Posted: 04 Jan 2008 at 4:21am
Er, what?  OK, where are these numbers coming from?  Are you doing something like summing a total of seconds, and then trying to convert it into minutes and seconds?


Posted By: irietek
Date Posted: 04 Jan 2008 at 7:17am
ohhh ok what's happening is that in my crystal report it's pulling hours and minutes in this format: H.M (example: 5.30)
This format is correct.. it means 5 hours and 30 minutes

but there are more than one record and I'm trying to get a total of them, and it's the total that screws up.

I would have records like
5.30
2.10
3.30

and Crystal reports would total it up to be 9.70 (9 hours 70 minutes).  I would like to change it to a regular hour and minute scheme I guess? As in turn that 9.70 into 10.10

I think I just confused myself here.




Posted By: BrianBischof
Date Posted: 06 Jan 2008 at 9:53pm
Interesting problem. I would divide the remainder by 60 to find out how many units of "hours" are in it and then use the remainder from that as the new number of minutes. Here is a formula I wrote for you. Replace the variable OldTime with whatever field has your time stored in it.
NumberVar OldTime := 3.72;
NumberVar NewTime;
NumberVar Hours;
NumberVar Minutes;
//Extract the number of hours
Hours := Int(OldTime);
//Get the decimal portion for minutes
Minutes := Remainder(OldTime, 1) * 100;
//Divide the minutes by 60 to increase the number of hours
Hours := Hours + Int(Minutes / 60);
//Get the remainder for the number of minutes left over
Minutes := Remainder(Minutes, 60);
//Add it all together to get back to the format you want
NewTime := Hours + (Minutes / 100);


I have complete coverage of all the mathematical functions and sample code for how to use them in Chapter 6 of my book http://www.amazon.com/exec/obidos/ASIN/0974953601/bischofsystem-20 - Crystal Reports Encyclopedia

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: irietek
Date Posted: 07 Jan 2008 at 12:30pm
It works!
thanks!!



Print Page | Close Window