time expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to calculate the difference between start time and stop time
however my formula datediff("n"[start time],[stop time]) only works if the
time does not cross over into a new day. ......such as 23:45 start time
and 00:15 stop time.. My answer should be 30 minutes in this example
but instead returns -1480.

I need to use military time . Can anyone help me figure this out? Thank
you in advance.
 
Hi,


Include the day in the date_time argument for start time, and stop time,
*OR* , add one day (24*60*CDec(60)) to the result if the result is negative,
assuming you JUST span one day.



Hoping it may help,
Vanderghast, Access MVP
 
I want to calculate the difference between start time and stop time
however my formula datediff("n"[start time],[stop time]) only works if the
time does not cross over into a new day. ......such as 23:45 start time
and 00:15 stop time.. My answer should be 30 minutes in this example
but instead returns -1480.

I need to use military time . Can anyone help me figure this out? Thank
you in advance.

What is the time difference between noon and 1pm?

49 hours, right? It is if it's noon Monday and 1pm Wednesday!

It's often best to take advantage of the fact that Access date/time
values can store both a date and a time. If you were storing
#7/31/2006 23:45# and #8/1/2006 00:15# in your table fields, the
DateDiff expression would work correctly.

If you can't (for some reason) do so, and you will never have more
than 24 hours at a stretch, you can use an expression like

DateDiff("n", [Start Time], [Stop Time]) + IIF([Start Time] > [Stop
Time], 1440, 0)

to "wrap" the time around midnight.

John W. Vinson[MVP]
 
YOUR MY HERO......THANK YOU SO MUCH

John Vinson said:
I want to calculate the difference between start time and stop time
however my formula datediff("n"[start time],[stop time]) only works if the
time does not cross over into a new day. ......such as 23:45 start time
and 00:15 stop time.. My answer should be 30 minutes in this example
but instead returns -1480.

I need to use military time . Can anyone help me figure this out? Thank
you in advance.

What is the time difference between noon and 1pm?

49 hours, right? It is if it's noon Monday and 1pm Wednesday!

It's often best to take advantage of the fact that Access date/time
values can store both a date and a time. If you were storing
#7/31/2006 23:45# and #8/1/2006 00:15# in your table fields, the
DateDiff expression would work correctly.

If you can't (for some reason) do so, and you will never have more
than 24 hours at a stretch, you can use an expression like

DateDiff("n", [Start Time], [Stop Time]) + IIF([Start Time] > [Stop
Time], 1440, 0)

to "wrap" the time around midnight.

John W. Vinson[MVP]
 

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

Back
Top