A
AccessDummy99
Hi
I am trying to do edit an existing query to find the difference between 2
dates and times (equalling a duration). For example:
1. Arrival Date 2. Arrival Time 3. DoctorTimeSeen Date 4. DoctorTimeSeen
Time
01/07/2008 08:44:00 01/07/2008
08:44:00
This is the case statement below that's already been written for me and it
works when the 2 dates/times are different however when they are the same
like the example above it returns 1440 minutes (24 hours) instead of 0
minutes.
Can anyone help. I'm totally stumped.
CASE WHEN (((((cast(edeArrivalDate AS int)) + (cast(LEFT (edeDoctorTimeSeen
, 2) AS decimal) / 24) + (cast(substring(edeDoctorTimeSeen , 4 , 2) AS
decimal) / 24 / 60)) - ((cast(edeArrivalDate AS int)) + (cast(LEFT
(edeArrivalTime , 2) AS decimal) / 24) + (cast(substring(edeArrivalTime , 4 ,
2) AS decimal) / 24 / 60))) * 24 * 60)) < 1 THEN (((((cast(edeArrivalDate AS
int) + 1)) + (cast(LEFT (edeDoctorTimeSeen , 2) AS decimal) / 24) +
(cast(substring(edeDoctorTimeSeen , 4 , 2) AS decimal) / 24 / 60)) -
((cast(edeArrivalDate AS int)) + (cast(LEFT (edeArrivalTime , 2) AS decimal)
/ 24) + (cast(substring(edeArrivalTime , 4 , 2) AS decimal) / 24 / 60))) * 24
* 60) ELSE ((((cast(edeArrivalDate AS int)) + (cast(LEFT (edeDoctorTimeSeen ,
2) AS decimal) / 24) + (cast(substring(edeDoctorTimeSeen , 4 , 2) AS decimal)
/ 24 / 60)) - ((cast(edeArrivalDate AS int)) + (cast(LEFT (edeArrivalTime ,
2) AS decimal) / 24) + (cast(substring(edeArrivalTime , 4 , 2) AS decimal) /
24 / 60))) * 24 * 60) END
Thanks
I am trying to do edit an existing query to find the difference between 2
dates and times (equalling a duration). For example:
1. Arrival Date 2. Arrival Time 3. DoctorTimeSeen Date 4. DoctorTimeSeen
Time
01/07/2008 08:44:00 01/07/2008
08:44:00
This is the case statement below that's already been written for me and it
works when the 2 dates/times are different however when they are the same
like the example above it returns 1440 minutes (24 hours) instead of 0
minutes.
Can anyone help. I'm totally stumped.
CASE WHEN (((((cast(edeArrivalDate AS int)) + (cast(LEFT (edeDoctorTimeSeen
, 2) AS decimal) / 24) + (cast(substring(edeDoctorTimeSeen , 4 , 2) AS
decimal) / 24 / 60)) - ((cast(edeArrivalDate AS int)) + (cast(LEFT
(edeArrivalTime , 2) AS decimal) / 24) + (cast(substring(edeArrivalTime , 4 ,
2) AS decimal) / 24 / 60))) * 24 * 60)) < 1 THEN (((((cast(edeArrivalDate AS
int) + 1)) + (cast(LEFT (edeDoctorTimeSeen , 2) AS decimal) / 24) +
(cast(substring(edeDoctorTimeSeen , 4 , 2) AS decimal) / 24 / 60)) -
((cast(edeArrivalDate AS int)) + (cast(LEFT (edeArrivalTime , 2) AS decimal)
/ 24) + (cast(substring(edeArrivalTime , 4 , 2) AS decimal) / 24 / 60))) * 24
* 60) ELSE ((((cast(edeArrivalDate AS int)) + (cast(LEFT (edeDoctorTimeSeen ,
2) AS decimal) / 24) + (cast(substring(edeDoctorTimeSeen , 4 , 2) AS decimal)
/ 24 / 60)) - ((cast(edeArrivalDate AS int)) + (cast(LEFT (edeArrivalTime ,
2) AS decimal) / 24) + (cast(substring(edeArrivalTime , 4 , 2) AS decimal) /
24 / 60))) * 24 * 60) END
Thanks