Link to home
Start Free TrialLog in
Avatar of JohnMac328
JohnMac328Flag for United States of America

asked on

SQL calaulate start time and end time between a date range

I need to calculate a start and end time between a date range.   This gives the date range and the different times.  I need Patient.AnesStartTime and Patient.EndStartTime calculated to show how much time for each patient between the date range.

SELECT     AnesStaff.AnesLastName, AnesStaff.AnesFirstName, Service.Service, Service.MEPERSCode, AnesStaff.FlagRelief, Patient.DateSurgery, Patient.AnesStartTime,
                      Patient.AnesEndTime
FROM         Service INNER JOIN
                      AnesStaff ON Service.PatientID = AnesStaff.PatientID INNER JOIN
                      Patient ON Service.PatientID = Patient.PatientID AND AnesStaff.PatientID = Patient.PatientID
WHERE     (Patient.DateSurgery BETWEEN CONVERT(DATETIME, '2008-03-01 00:00:00', 102) AND CONVERT(DATETIME, '2008-04-01 00:00:00', 102))

ThanksUser generated image
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JohnMac328

ASKER

Thanks that seems to work.  I agree with your statements but this is a deployed system and those changes are not allowed since it has been sunsetted.  I have seen other reports with the times displaying like your example shows.  Reports are still allowed.
Thanks again