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

query shows calculated datediff > 24 hrs

Status
Not open for further replies.

jjb373

MIS
Feb 4, 2005
95
US
My table has two date fields both having a date and time (ex: 12/05/2005 12:05:00 PM). My goal is finding the difference between 2 times. In a query, I converted this time difference from a date/time format to look like this: __ days __hrs __min.
I was wondering how I could also show only those times(records) that are greater than 24 hours with this query or using another query along with my current one. (anything being greater than 24 hrs is shown and anything under is not displayed.

Here is my current query:
SELECT Documents.[Record Number], Documents.[Date of Appointment], Int(DateDiff("n",Documents![Date of Appointment],Documents![HX Documents])/1440) & "day " & Format(DateDiff("n",Documents![Date of Appointment],Documents![HX Documents])/1440,"h""hr ""n") & "min" AS [HX Late], Int(DateDiff("n",Documents![Date of Appointment],Documents![Prospective Documents])/1440) & "day " & Format(DateDiff("n",Documents![Date of Appointment],Documents![Prospective Documents])/1440,"h""hr ""n") & "min" AS [Prospective Late], Int(DateDiff("n",Documents![Date of Appointment],Documents![External Documents])/1440) & "day " & Format(DateDiff("n",Documents![Date of Appointment],Documents![External Documents])/1440,"h""hr ""n") & "min" AS [External Late]
FROM Documents
WHERE (((Documents.[Date of Appointment]) Between [Enter Start Date (ex: mm/dd/yyyy)] And [Enter End Date (ex: mm/dd/yyyy)]));

Any advice is greatly appreciated.. I know this query is ugly.
 
One more request for this. This query above is used for a report.

For each of the documents in this query, HX Documents, Prospective Documents, External Documents...I want to do a count function. I am looking to find the total of records that have data added for each one. Then I need the count for all that are over 24 hours. This is for each of the 3 types of documents.

I may need to get the total count of documents added from the Documents table and the total over 24 hours from the query.

After that I want to divide the 2 totals for that document and find a percentage.

Does anyone have any suggestions?

For example

Table Query result
Appt. Date HX Documents HX > 24hrs time
12/05/05 1:00PM 12/05/05 5:00PM 0d 4hr 0min
12/05/05 1:00PM 12/06/05 3:15PM 1d 2hr 15min
12/05/05 2:00PM 12/07/05 3:30PM 2d 1hr 30min

The total would be: 3 2
Percentage: 67%

I hope this is clear enough.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top