Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Date AND Time calculation help please

0 views
Skip to first unread message

Jager

unread,
Aug 10, 1999, 3:00:00 AM8/10/99
to
I have been developing an access database for my job on orders from
above. I have been using access and making databases for a year or so
but doing the vb code and functions and a lot of what I am trying to
do now is very new to me
I have a list of 2 dozen things I am trying to accomplish but this is
the one I am beating my head on my desk about now

This database is for tracking workorders
I was told to have it calculate job duration in days and hours

I do have to say these newsgroups have been a big help as well as Dev
Ashish's web site

I just wish I could understand more of what I am reading sometimes

I have perused the newsgroups and internet for the past week and all I
have found is calculations based on the date, nothing about date AND
time.

How would I accomplish this?


Keri Hardwick

unread,
Aug 10, 1999, 3:00:00 AM8/10/99
to
Look at DateDiff, calculate in hours, divide by 24 to get the days,
remainder is hours.

Keri
Jager wrote in message <37b0780e....@news.supernews.com>...

Robin Stoddart-Stones

unread,
Aug 10, 1999, 3:00:00 AM8/10/99
to
To repeat what is on Dev's site.

A date datatype is a double, measuring days.

The integer part is the completed day, the decimal part the fraction
of the uncompleted day. We tend to call this the TIME meaning time of
day.

If you subtract one date type from another the result is a date type
that needs decoding if you are interested in elapsed time.

ie: if you start the job at 06:00 1-Jan-1999 and finish at 12:00
2-Jan-99 then you want the duration to be 1 day, 6 hours.

If you do math in date types then

duration=Startdate-EndDate

(duration now =1.25)

now you can calculate the days by INT(duration)
and you can format the time by FORMAT(TIMEVALUE(duration),"h")

(if you want greater accuracy format the time by "short Time" which
will give you hours minutes and seconds).

Thus the duration output will be Int(duration) & " Days " &
Format(Timevalue(duration),"h") & " Hours"

the nice thing about the calculation is that if the job was progressed
in several sessions, you can do all the calculation with a simple
addition.

If you have a recordset for a job with several start and end of
session then
Duration=0
do until rs.EOF
duration=duration+(rs!EndDate-rs!StartDate)
rs.move 1
loop

will sum all the elapsed time into one duration. Assume 3 records each
of 1.25 days duration then the total= 3.75 days.

(This can be neatly handled by a totals query as well)

The output line above will convert that to 3 days 16 hours for you.

In other words only convert from the Date datatype when you need to
format the answer.

Have Fun
Robin

Jager

unread,
Aug 11, 1999, 3:00:00 AM8/11/99
to
Both replies are great but I want to do the one that Robin
Stoddart-Stones posted.

I want to have this do minutes as well but I will play with that after
I get this working right.

Can you tell me how to correct this
Thanks a lot!!!!

both worked well but I used the help
posted by Robin Stoddart-Stones
and I added minutes too for a more detailed report

I really appreciate the replies and how quick I got them

Now on to another one of the 2 dozen things the boss wants me to add
to this database

:- >

0 new messages