Solved

Test condition and convert number to negative

Posted on 2014-02-14
5
284 Views
Last Modified: 2014-02-21
I would like to check a field IF AttendDet.ActClockIn = 12:00 or 22:30 and AttendDet.TotActTime = 0.50 THEN convert the 0.50 to a negative number, ELSE null or nothing.
0
Comment
Question by:Lee Ingalls
  • 3
5 Comments
 
LVL 7

Author Comment

by:Lee Ingalls
ID: 39860636
I figured out how to get the number to negative by multiplying it by (-1)... now for the rest of it.
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 250 total points
ID: 39861224
You said "null or nothing".  Will 0 (zero) do?  If not, you may need to explain in more detail what you're trying to do.

 What type of field is ActClockIn?  Time or datetime or something else?

 Assuming that it's a time, you could use something like this:

if ({AttendDet.ActClockIn} = Time (12, 00, 00) or
 {AttendDet.ActClockIn} = Time (22, 30, 00)) and
 {AttendDet.TotActTime} = 0.50 then
  0 - {AttendDet.TotActTime}
else
  0


 You could use {AttendDet.TotActTime} * -1 if you prefer.  Subtraction is more efficient than multiplication, but depending on how CR performs the calculations, it may end up performing the same operations either way.

 FWIW, technically, since you're looking for one specific value (.5), you could replace "0 - {AttendDet.TotActTime}" with -0.5.  That would theoretically be more efficient, but using the calculation may more clearly express what the formula is doing.

 James
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
ID: 39861408
Is clockin a time?

If not you will have to pull the time out of it.  Most databases don't have a TIME datatype but simulate it with a datetime with the date set to a default value like 1 Jan 1900

Using James formula

if (Time({AttendDet.ActClockIn}) = Time (12, 00, 00) or
 Time({AttendDet.ActClockIn}) = Time (22, 30, 00)) and
 {AttendDet.TotActTime} = 0.50 then
    - {AttendDet.TotActTime}
else
    0

Open in new window


The other possibility is that CLockIn is a string

if ({AttendDet.ActClockIn} = '12:00' or
 {AttendDet.ActClockIn} = '22:30') and
 {AttendDet.TotActTime} = 0.50 then
    - {AttendDet.TotActTime}
else
    0

Open in new window


You really don't need to subtract from 0

mlmcc
0
 
LVL 7

Author Comment

by:Lee Ingalls
ID: 39876837
OK, sorry for the delay.
The ActClockIn field type is string.
I realized that by changing the sign of the {AttendDet.TotActTime} amount of 0.50 to negative it was doubling the effect I was looking. So I simply changed it to, THEN 0

IF {AttendDet.ActClockOutTime}='12:30' OR {AttendDet.ActClockOutTime}='23:00' AND
{AttendDet.TotActTime}=0.50 THEN 0
ELSE {AttendDet.TotActTime}

'12:30' and '23:00' are the times that the automatic break calculations end. I erroneously had the second break end time set at '22:30' changed to '23:00'...
I needed to filter out the automatic break time.

Thank you James0628 and mlmcc for your always valuable assistance!

BudELee
0
 
LVL 7

Author Closing Comment

by:Lee Ingalls
ID: 39877462
You both answered the original question; then I changed it once I realized I had misstated my requirement. As always I value your input.

Cheers, Lee
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now