selct query to find elapsed time

SlinkRN

Well-known Member
Joined
Oct 29, 2002
Messages
715
Hi,
My boss wants to know the total time between admit of a patient and birth of her baby. This information is in an Access program and I can do a select query to find it, but I can't figure out how to do it :( In the database, the admit date, admit time, delivery date, and delivery time are all separate fields. In the query I made a new field called "AdmitToDel" but I don't know how to get the difference since the date and times are in separate fields. I'm more of an Excel person myself so I'm always lost in Access. Can anyone help? I've done a search and I've looked through my Helen Feddema book but can't find an answer. Thanks! Slink
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi
To get the elapsed days, use something like this in a query :

Days : DateDiff("d", [AdmitDate], [DeliveryDate])-IIf([DeliveryTime] < [AdmitTime], 1, 0)

Make sure you use your actual field names.

To get the hours (over and above the days), use this in the same query :
Hours : (DateDiff("n", [AdmitTime], [DeliveryTime]) + IIf([DeliveryTime] < [AdmitTime], 1440, 0))/60

To merge the 2 parts into one field, you could use this instead :
Combined: DateDiff("d", [AdmitDate], [DeliveryDate]) - IIf([DeliveryTime] < [AdmitTime], 1, 0) & " Days, " & Format((DateDiff("n", [AdmitTime], [DeliveryTime]) + IIf([DeliveryTime] < [AdmitTime], 1440, 0))/60, "0.0") & " Hours"

If you want to break the hours down into hours and minutes then have a go working out the difference between the hours part of the time and the minutes part of the time.

HTH, Andrew
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,242
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top