HELP: Date Calculations

T

Tim

What formula do I need to use to calculate the number of minutes that have
elapsed between a START TIME and an END TIME.

I.E.

START TIME END TIME # of MINUTES
2:00 AM 3:45 AM 105
 
J

John Vinson

What formula do I need to use to calculate the number of minutes that have
elapsed between a START TIME and an END TIME.

I.E.

START TIME END TIME # of MINUTES
2:00 AM 3:45 AM 105

DateDiff("n", [Start Time], [End Time])

will do it. Despite the name, DateDiff can calculate differences in
any unit from seconds to years.

Note that it's "n" for miNutes, and "m" for Months.

John W. Vinson[MVP]
 
D

DianaS

Hi, your post was helpful to me. However, I am having difficulty displaying
the query results in a form that I have created.

I have the following fields:
[StartTime], [EndTime], and [TourLength]

I succesfully created a query that gives TourLength in minutes. However, in
the form, I do not know how to link the [TourLength] field to the query
results.

Thanks,
Diana

Allen Browne said:
Try the DateDiff() function:
DateDiff("n", [Start Time], [End Time])

More details:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Tim said:
What formula do I need to use to calculate the number of minutes that have
elapsed between a START TIME and an END TIME.

I.E.

START TIME END TIME # of MINUTES
2:00 AM 3:45 AM 105
 
R

Rick B

If you calculated it in the query, then you gave it a name. Just pull that
name from the field list in your report.

Your query probably has a column with something like....

TourLength: DateDiff("n", [Start Time], [End Time])


If so, just pull the "TourLength" to your form.


--
Rick B



DianaS said:
Hi, your post was helpful to me. However, I am having difficulty displaying
the query results in a form that I have created.

I have the following fields:
[StartTime], [EndTime], and [TourLength]

I succesfully created a query that gives TourLength in minutes. However, in
the form, I do not know how to link the [TourLength] field to the query
results.

Thanks,
Diana

Allen Browne said:
Try the DateDiff() function:
DateDiff("n", [Start Time], [End Time])

More details:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Tim said:
What formula do I need to use to calculate the number of minutes that have
elapsed between a START TIME and an END TIME.

I.E.

START TIME END TIME # of MINUTES
2:00 AM 3:45 AM 105
 
D

DianaS

Hello,

In reference to what Rick B wrote, how does one "pull" a field name into a
form? I tried linking my query result [Minutes] to the field name
[TourLength] found in my data-entry form by inserting
"=[QueryTourLength]![Minutes]" into ControlSource (found in the properties of
the [TourLength] field). However, this approach did not work.

I would like to directly add the [Minutes] field by using the "Field List"
tool. However, this tool contains only a list of fields from one table. Is
there a way to add fields to this list from other tables and queries? Maybe
this will solve my problem. Thank you.

Diana

Rick B said:
If you calculated it in the query, then you gave it a name. Just pull that
name from the field list in your report.

Your query probably has a column with something like....

TourLength: DateDiff("n", [Start Time], [End Time])


If so, just pull the "TourLength" to your form.


--
Rick B



DianaS said:
Hi, your post was helpful to me. However, I am having difficulty displaying
the query results in a form that I have created.

I have the following fields:
[StartTime], [EndTime], and [TourLength]

I succesfully created a query that gives TourLength in minutes. However, in
the form, I do not know how to link the [TourLength] field to the query
results.

Thanks,
Diana

Allen Browne said:
Try the DateDiff() function:
DateDiff("n", [Start Time], [End Time])

More details:
Calculating elapsed time
at:
http://allenbrowne.com/casu-13.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

What formula do I need to use to calculate the number of minutes that have
elapsed between a START TIME and an END TIME.

I.E.

START TIME END TIME # of MINUTES
2:00 AM 3:45 AM 105
 
Top