Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Convert hour/minutes to units(days) Post Reply Post New Topic
<< Prev Page  of 3 Next >>
Author Message
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Posted: 27 Apr 2009 at 8:18am
If I drop the val() partof the formula, I get a message saying "A number, or currency amount is required here".  Sorry to be a pain.  Thanks for your quick response.
With power comes great responsibility!
IP IP Logged
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Posted: 27 Apr 2009 at 8:29am
Sorry I think you was correct the first time.  They are passed in as strings.  But the formula is just adding up what is in both fields?
With power comes great responsibility!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Apr 2009 at 9:07am
val({estimated hours}) + val({estimated minutes})/60
will add the hours to the minutes after they are divided by 60 (turing it into an hour format) and round to the nearest number with no decimals.
E.g.
2 hours + 40 minutes/60 = 3
2 hours + 29 minutes/60=2
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Apr 2009 at 6:20am
I wouldn't think that this would round, unless you set the rounding value for the formula...which is probably the easiest way to go about it.
 
I am just wondering how the estimated times relates to actual...it they estimate 2 hours, and have 4 of those in 1 day, then the day is 8 hours, but they could estimate 1 procedure at 7 hours and that would be a day...so it just seems a bit confusing...but it might make perfect sense in the company.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Apr 2009 at 6:56am
Lockwelle, I thought this would not round either but in a basic testing of it it did. Not sure if my "test" was legitimate but surprisingly it was the end result. 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 28 Apr 2009 at 7:24am
Well, that is something to watch for...not sure that I would always want it to round.
IP IP Logged
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Posted: 29 Apr 2009 at 1:51am
Hi, thanks for your responses.  the formula I am using is:

 val({EstimatedHours}) + val({EstimatedMinutes}) / 60.  The /60 part does not seem to do anything though, is this because its a string?  This does work for the values you sent, but if there was say 70hours, then 70units are displayed?  Where as it should be 40units for 70hours.

Sorry to be a pain.

This is the way they want it displaying, hope you can help and thank you again.




Edited by crystal_newbiee - 29 Apr 2009 at 1:53am
With power comes great responsibility!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 29 Apr 2009 at 6:14am
this just gives the hours, not the units. for the units you need to perform a conversion.  Are these times for the details, and you will sum the details to create a total of units for a week or other time period?  If so, you might want to do something like:
local numbervar thisTime:=val({EstimatedHours}) + val({EstimatedMinutes}) / 60;
local numbervar thisUnit:=0;
shared numbervar totalUnits; //(optional, if aggregate needed)
if thisTime>=1.75 and thisTime <2 then
 thisUnit :=1
else
 if thisTime >= ... and thisTime < ... then
   thisUnit:=2...
I think you get the idea.
 
totalUnits := totalUnits + thisUnit; //(optional, for the aggregate)
thisUnit  //display the units calculated
 
if you use the aggregates, you will need a formula to display them and one to reset to 0 when the group changes.
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Apr 2009 at 6:28am
Could you change this to total minutes / 105 (one unit)?
(val({EstimatedHours})*60 + val({EstimatedMinutes})) / 105
IP IP Logged
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Posted: 29 Apr 2009 at 8:05am
Hi,

Yes it can be changed to total minutes, is this an easier way?

Ok so I created the NumberVar within the same formula, wont I need to create a quite a big IF statement by doing it this way though?  The total will be needed.  The Units are purely for report use.

Could I do it like:

1 unit   = 105mins
2 units = 210mins
3 units = 315mins
4 units = 420mins......etc.

I will know the figures are right when the value for say 70hours(10 days) equals to 40 units.  For this I did 70(hours) * 60(minutes) = 4200(minutes) / 105(unit) = 40units.

I hope this makes sense and really appreciate your help guys.

Thanks.

@DBlank - yes this formula worked:

(val({OutstandingJobSheets_txt.EstimatedHours})*60 + val({OutstandingJobSheets_txt.EstimatedMinutes})) / 105

Thank you both very much.  Think I am going to have to learn crystal reports alot more as it's required quite alot in my job.  It looks to be outputting what I need but will reply again.

Cheers.





Edited by crystal_newbiee - 29 Apr 2009 at 8:28am
With power comes great responsibility!
IP IP Logged
<< Prev Page  of 3 Next >>
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.