Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Datediff function

Status
Not open for further replies.
Dec 1, 2009
17
US
Hi all,

I currently have a Crystal Reports 8.5 daily hours report that does a Datediff on the clock-in and clock-out times of a user. This part works fine assuming the user has clocked out. If the user has not yet clocked out the report returns blank. What I am trying to do is get the report to display the daily hours regardless of whether or not the user has clocked out by creating a conditional statement filling in the current date/time when necessary:

--------
if {Time.ClkOut} = #1/1/1900# then
Datediff("n",{Time.ClkIn},CurrentDateTime)
else
Datediff("n",{Time.ClkIn},{Time.ClkOut})
--------
When I run this the report is still blank if the user has not clocked-out.

1/1/1900 is the default for the ClkOut field when the initial entry is made and before it is updated.

Any help would be much appreciated!
 
Try:

if isnull({Time.ClkOut}) or
{time.clkout} = datetime(1900,1,1,0,0,0) then
Datediff("n",{Time.ClkIn},CurrentDateTime) else
Datediff("n",{Time.ClkIn},{Time.ClkOut})

-LB

 
Thanks for the reply! I have looked a little deeper and found that my initial problem is with a select formula...

I will try to work that out and then use your suggestion if I am still having problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top