Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Change time from number to regular time Post Reply Post New Topic
Author Message
irietek
Newbie
Newbie


Joined: 03 Jan 2008
Online Status: Offline
Posts: 4
Quote irietek Replybullet Topic: Change time from number to regular time
    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


Edited by irietek - 03 Jan 2008 at 11:12am
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 03 Jan 2008 at 11:38am
Ah, I probably should have titled my post better.  Check out 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.


IP IP Logged
irietek
Newbie
Newbie


Joined: 03 Jan 2008
Online Status: Offline
Posts: 4
Quote irietek Replybullet 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

IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet 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?
IP IP Logged
irietek
Newbie
Newbie


Joined: 03 Jan 2008
Online Status: Offline
Posts: 4
Quote irietek Replybullet 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.


IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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 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>
IP IP Logged
irietek
Newbie
Newbie


Joined: 03 Jan 2008
Online Status: Offline
Posts: 4
Quote irietek Replybullet Posted: 07 Jan 2008 at 12:30pm
It works!
thanks!!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.