calculating time

G

Guest

Hi

In my form i have 3 fields, [starttime], [endtime] and a field [total] to
get the difference between start and end. I want a field in a subform to get
the sum of the [total].

I use [endtime]-[starttime] to get the [total], and sum([total]) in the
subform but if there are more than 24 hours i doesn't work.

What can i do, - please help

/beli
 
A

Allen Browne

As AlCamp says, you can use DateDiff() to get the difference in minutes.

Example, and explanation of how to display the result as hours and minutes
in:
Calculating elapsed time
at:
http://members.iinet.net.au/~allenbrowne/casu-13.html

BTW, you should not be storing Total in the table. It should only be a
calculated field in the query, unless their is some valid reason why
sometimes it should NOT be the same as the difference between the other 2
fields.
 
G

Guest

Thanks,

I will not store the calculation in a table. It's only for the user to chek
the "total"time.

=Sum(DateDiff("n";[Starttime];[Endtime]))/60
It works perfect, but what can I do if I only wants to calculate entries
whit 1, 2 or 3 in a field named "art" and show it on the form.

My Table look like this
[ID] [Starttime] [Endtime] [Art]

As you can see, - I'm very new to Access.

/beli

"Allen Browne" skrev:
As AlCamp says, you can use DateDiff() to get the difference in minutes.

Example, and explanation of how to display the result as hours and minutes
in:
Calculating elapsed time
at:
http://members.iinet.net.au/~allenbrowne/casu-13.html

BTW, you should not be storing Total in the table. It should only be a
calculated field in the query, unless their is some valid reason why
sometimes it should NOT be the same as the difference between the other 2
fields.

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

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

beli said:
Hi

In my form i have 3 fields, [starttime], [endtime] and a field [total] to
get the difference between start and end. I want a field in a subform to
get
the sum of the [total].

I use [endtime]-[starttime] to get the [total], and sum([total]) in the
subform but if there are more than 24 hours i doesn't work.

What can i do, - please help

/beli
 
A

Allen Browne

Try:
=Sum(IIf([Art] = 1 OR [Art] = 2 OR [Art] = 3,
DateDiff("n";[Starttime];[Endtime]))/60, 0))

It may be better to use a Query as the RecordSource of your form. In the
Field row of the query, enter:
Minutes: IIf([Art] = 1 OR [Art] = 2 OR [Art] = 3,
DateDiff("n";[Starttime];[Endtime])), 0)
You can then sum the Minutes in your form.

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

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

beli said:
Thanks,

I will not store the calculation in a table. It's only for the user to
chek
the "total"time.

=Sum(DateDiff("n";[Starttime];[Endtime]))/60
It works perfect, but what can I do if I only wants to calculate entries
whit 1, 2 or 3 in a field named "art" and show it on the form.

My Table look like this
[ID] [Starttime] [Endtime] [Art]

As you can see, - I'm very new to Access.

/beli

"Allen Browne" skrev:
As AlCamp says, you can use DateDiff() to get the difference in minutes.

Example, and explanation of how to display the result as hours and
minutes
in:
Calculating elapsed time
at:
http://members.iinet.net.au/~allenbrowne/casu-13.html

BTW, you should not be storing Total in the table. It should only be a
calculated field in the query, unless their is some valid reason why
sometimes it should NOT be the same as the difference between the other 2
fields.

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

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

beli said:
Hi

In my form i have 3 fields, [starttime], [endtime] and a field [total]
to
get the difference between start and end. I want a field in a subform
to
get
the sum of the [total].

I use [endtime]-[starttime] to get the [total], and sum([total]) in the
subform but if there are more than 24 hours i doesn't work.

What can i do, - please help

/beli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top