CALCULATING TIME FROM ONE FILED

Shafique

Board Regular
Joined
Nov 23, 2018
Messages
119
Hi Everyone
I have a Subform that linked with a form's ID (Primery Key) and stored the data with forms BATCH_No (Unique ID)
"as shown in attachment
Here is want to SUM the Subform's RTIME Field's total duration
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Thanks for your attention Sir.
Iwant share something with maybe it solve the issue
I HAVE TWO TABLES
1: BATCH
2:B_RECIPE
I put this function in a unbound TEXTBOX IN form (BATCH)
=Dsum("RTIME","B_RECIPE","RID='"&[FORMS]![BATCH]![BATCH_NO]&"'")

THE B_RECIPE IS A SUBFORM AND IT'S [RID] IS LINKED WITH "BATCH" FORM's ID.
IN [RID] DATA WE STORE [BATCH_NO] ALSO.


SO ONE BATCH [ID] HAS MANY [RID] RECORDS IN [RTIME].
I WANT TO CALCULATE ALL RTIME FIELD THAT ASSOCIATES WITH BATCH_NO.
 
Upvote 0
in This Pic on subform a field named
RTIME with data
11:32 am
11:34 am
2:30 pm
and lots of more will be come with Time
i want to know the duration from First Time record (11:32 am) To last Time record (2:30 pm)
e.g.. 02:58
 

Attachments

  • Untitled-1.jpg
    Untitled-1.jpg
    178.3 KB · Views: 9
  • WhatsApp Image 2021-12-12 at 8.55.46 PM.jpeg
    WhatsApp Image 2021-12-12 at 8.55.46 PM.jpeg
    57.4 KB · Views: 9
Upvote 0
I Tried Lot's of variants e.g..
=DSum("[RTIME]","B_RECIPE","[RID]='" & DLookUp("[BATCH_No]","BATCH","[BATCH_No]='" & [Forms]![BATCH]![BATCH_No] & "'") & "'")
but when is do like this =DSum("[RTIME]","B_RECIPE") then it calculate without critera (BATCH_No)
 
Upvote 0
You cannot determine a time span by summing. 11:23 is 23 minutes after 11 A.M. If you add a similar time component you will simply create a new time on the clock. So 10:23 + 01:05 will be 11:28 AM, not some total. To determine a time span use DateDiff function but you will need to include the day date.
 
Upvote 0
You cannot determine a time span by summing. 11:23 is 23 minutes after 11 A.M. If you add a similar time component you will simply create a new time on the clock. So 10:23 + 01:05 will be 11:28 AM, not some total. To determine a time span use DateDiff function but you will need to include the day date.
I am very thankful for your valuable suggestion.
I will try. It will be more easy for me if you put some sample. how to way out.
 
Upvote 0
It will be more easy for me if you put some sample.
I'll bet it would be easier for me to hand you the proverbial fish instead of teaching you how to fish. However, you have to put some effort into it. Google ms access datediff function and see what it does. As I indicated, you will likely need date values along with your times. I pointed that out, but I am none the wiser about your data after your response.

This will result in a calculation of 23 hours.
datediff("h",#01/21/2021 11:30:00 AM#,#01/22/2021 10:30:00#)

However, if all of your dates/times are in one field, you will probably have to create a calculated query field in a Totals query. Totals query will allow you to group by one or more other fields if you need to do that. Also, you might have to create 3 calculated fields like
Expr1: DMax(of field, with criteria perhaps)
Expr2: DMin(of field, with criteria perhaps)
Expr3: [Expr1] - [Expr2])

Another possibility is that you would need to use a subquery. I am just throwing ideas out here as I have no idea what your data looks like. Perhaps you will have to research DMax and DMin functions and/or subqueries.
 
Upvote 0
Solution

Forum statistics

Threads
1,221,531
Messages
6,160,353
Members
451,640
Latest member
idavies1402

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