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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement not working

Status
Not open for further replies.

capronton

MIS
Jun 28, 2013
159
US
Can someone explain why this if statement is not working?

If DateDiff ("s", {incident_log.sched_time},{incident_log.incident_date_time} ) < -30 then "Early" else
If DateDiff ("s", {incident_log.sched_time},{incident_log.incident_date_time} ) > 330 then "Late" else
else "OnTime"

If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*SOUTH*" and {incident_log.tp_id} = 12790
then "OnTime" else
If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*NORTH*" and {incident_log.tp_id} = 12782
then "OnTime"
If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*NORTH*" and {incident_log.tp_id} = 12763
then "OnTime
 
What is not working? I personally would have done the last two if's differently

If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*NORTH*" and
({incident_log.tp_id} = 12790 or {incident_log.tp_id} = 12763))
then "OnTime"


Then of course, if all the if's fail, then you will have a NULL return.
 
The Last 3 If statements are not executed for some reason. Can someone explain why?
 
For some reasons I'm not getting any "Lates" on special conditions. Please see below.
Can anyone explain why?


If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*SOUTH*" and {incident_log.tp_id} = 12790
then "OnTime" else
If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*NORTH*" and {incident_log.tp_id} = 12782
then "OnTime" else
If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*NORTH*" and {incident_log.tp_id} = 12763
then "OnTime" else
If DateDiff ("s", {incident_log.sched_time},{incident_log.incident_date_time} ) < -30 then "Early" else
If DateDiff ("s", {incident_log.sched_time},{incident_log.incident_date_time} ) > 330 then "Late" else "OnTime
 
Is it possible there simply isn't any "Lates" for the data you are returning? Are you certain you are using the correct date fields in the Datediff code?

For troubleshooting purposes, create the following formula, place it on the report and review the results.

Code:
DateDiff ("s", {incident_log.sched_time},{incident_log.incident_date_time})

Hope this helps.

Cheers
Pete

 
This is my first opportunity to respond. I solved the problem using the syntax below.

If {incident_log.current_route_id} = 987 and {direction_codes.direction_description} like "*SOUTH*" and {@earlyLate} = "Early" and {incident_log.tp_id} = 200
then "OnTime" else
If {incident_log.current_route_id} = 987 and {direction_codes.direction_description} like "*SOUTH*" and {@earlyLate} = "Early" and {incident_log.tp_id} = 58
then "OnTime" else
If {incident_log.current_route_id} = 987 and {direction_codes.direction_description} like "*SOUTH*" and {@earlyLate} = "Early" and {incident_log.tp_id} = 292
then "OnTime" else
If {incident_log.current_route_id} = 103 and {direction_codes.direction_description} like "*NORTH*" and {@earlyLate} = "Early" and {incident_log.tp_id} = 12763
then "OnTime" else {@earlyLate}

Will do Pmax.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top