Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Formula Help Post Reply Post New Topic
Author Message
loula1978
Newbie
Newbie


Joined: 21 May 2013
Online Status: Offline
Posts: 2
Quote loula1978 Replybullet Topic: Formula Help
    Posted: 22 May 2013 at 5:05am

I am looking help writing a couple of formulas in crystal.

I need a formula that will convert decimal into HH:MM and a formula that will ensure that the end date field in sickness reports will only show if the field called Return to work is showing as yes, currently even if the person hasn’t returned to work the end date shows.

Can anyone help?

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 23 May 2013 at 1:03pm
What is the decimal data that needs to be converted to HH:MM?  Is there a calculation required?
 
For the other issue,
 
1.  Right-click on the end date field on your report and select "Format...".
2.  Click on the button to the right of "Suppress"  (DO NOT check the suppress checkbox!)
3.  Enter a formula like the following:
 
IsNull({Return to work field}) or {Return to work field} <> 'Yes'
 
- Modify this to use the exact field and the appropriate value in the field.  If there is no chance that the field will ever be null (empty), then you can leave the "IsNull()" part off of the formula.
 
-Dell
IP IP Logged
loula1978
Newbie
Newbie


Joined: 21 May 2013
Online Status: Offline
Posts: 2
Quote loula1978 Replybullet Posted: 23 May 2013 at 10:43pm
Thanks for that formula.
 
with regards to the decimal data that i am looking to convert, it is data like 7.8, 7.5, etc that needs to be put into time.  This data is the time a person is on shift in decimal format, I dont think a calculation is needed as the field is already entered in decimal format on our HR system but im not sure.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 24 May 2013 at 5:33am
Actually, you'll have to use a calculation to convert the decimal to minutes.  Here's an example of what this might look like.
 
NumberVar Hours := 0;
NumberVar Minutes := 0;
If not IsNull({MyTable.Time}) then
(
  Hours := {MyTable.Time} \ 1; 
  Minutes := ({MyTable.Time} - Hours) * 60;
);
ToText(Hours, 0, "") + ":" + ToText(Minutes, 0, "")
 
Note the use of the backslash "\" in the Hours calculation.  This is "Integer Divide" which will just give you the integer portion of the calculation without the numbers after the decimal.
 
If you need this to be an actual Time value as opposed to just text for display, change the final part of the formula to:
 
Time(Hours, Minutes, 0,)
 
NOTE:  When working with variables, you'll need to use ":=" for assignment where you would use just "=" in formulas without a variable.  Also, note where I've put the semi-colons, they're important for getting this to process correctly.  DO NOT put a semi-colon at the end of the last line or else the value won't display on the report.
 
-Dell
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.031 seconds.