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
Author Message
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 29 Apr 2009 at 8:14am
if you're units are based on 105 minutes, you can simplify the calculation of units.
 
local numbervar thisUnits;
thisUnits := ROUND(totalMinutes / 105)
 
all depends, if the estimate is for 130 minutes, how many units is it?  Or can this not happen?
 
If 105 minutes is the 'unit' all you need to do is divide, so the if statement is simple...it is if there are any 'extra' minutes to account for, and how to do that.
 
 
 
IP IP Logged
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Posted: 01 May 2009 at 6:56am
Hi,

yes the units are based on 105minutes.  The formula is working at present for character values.  But I have another report which has numeric values, so I changed the formula to:

{OutstandingJobSheets_txt.EstimatedHours}*60 + {OutstandingJobSheets_txt.EstimatedMinutes} / 105

But this give strange results.  For example, 6hours 30minutes is displayng as 360?  Also, there are occasions when 0units are displayed on the initial report.  Like for 0 hours 45 minutes no units are displayed when 1 unit should be displayed.

The estimate for 130 minutes would display 2 units, so there is an easier way to do this would you say?  Thanks again, response time from you both has been excellent.

Kev


With power comes great responsibility!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 01 May 2009 at 7:00am
you need ()...it is taking hour/60 then adding minutes/105
you want (hour/60+minutes)/105
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 May 2009 at 7:00am
You need to parenth the first part of the statement so that it does the addition of the two then divide that by 105. Your statement is is dividing the minutes only:
({OutstandingJobSheets_txt.EstimatedHours}*60 + {OutstandingJobSheets_txt.EstimatedMinutes}) / 105


Edited by DBlank - 01 May 2009 at 7:01am
IP IP Logged
crystal_newbiee
Newbie
Newbie


Joined: 23 Jul 2008
Online Status: Offline
Posts: 15
Quote crystal_newbiee Replybullet Posted: 01 May 2009 at 8:16am
Thanks, and how can I make it so that the units are always greater than 0?  Say if the job is only 10 or 20minutes?  can I add this to the same formula as the unit should never be below 1. thanks again.

Kev
With power comes great responsibility!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 May 2009 at 8:18am
if
({OutstandingJobSheets_txt.EstimatedHours}*60 + {OutstandingJobSheets_txt.EstimatedMinutes}) / 105 <1 then 1
else
({OutstandingJobSheets_txt.EstimatedHours}*60 + {OutstandingJobSheets_txt.EstimatedMinutes}) / 105
IP IP Logged
<< Prev Page  of 3
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.032 seconds.