benjiiiii
benjiiiii

Reputation: 478

If less than 0 set to Null/Blank - SQL Reporting Services

I have the following expression running for my report.

=DateDiff(DateInterval.Hour, Fields!ClockedIn.Value, Fields!ClockedOut.Value)

Whilst this works for what I need it to, if a user forgets to clock out then I need it to set the hours worked value to be blank or come up with a message saying something like - "User not yet clocked out"

Is this simple to do?

EDIT: I have attempted the following - Is this the correct approach?

=IIf((DateDiff(DateInterval.Hour, Fields!ClockedIn.Value, Fields!ClockedOut.Value)<0 = TRUE, "User not clocked out", DateDiff(DateInterval.Hour, Fields!ClockedIn.Value, Fields!ClockedOut.Value)))

Currently this is erroring on the comma after TRUE

Upvotes: 0

Views: 427

Answers (1)

Ravi
Ravi

Reputation: 1172

try this....

 =IIf((DateDiff(DateInterval.Hour, Fields!ClockedIn.Value, Fields!ClockedOut.Value)<0, NULL, DateDiff(DateInterval.Hour, Fields!ClockedIn.Value, Fields!ClockedOut.Value))

Upvotes: 1

Related Questions