counting time

J

Jean-Paul

Hi,
I have a table with 3 "time" fields:
1 starttime
1 stoptime
1 "worked time"

I created a querry to calculate the "worked time" (simple:
stoptime-starttime)

Finally I have to sum all "worked time"s together
I do this with following SQL:

sql = "SELECT Sum(Uren.gewerkt) AS SomVanUur FROM Uren WHERE
Uren.Datum > #" & Format(Forms![Uur_overzicht]!Start_dat, "DD/MM/YYYY")
& "# And Uren.Datum < #" & Format(Forms![Uur_overzicht]!Stop_dat,
"DD/MM/YYYY") & "# ;"
Set kost = db.OpenRecordset(sql)

Then I enter the value in an entryfield:

Me!rek = Format(kost!somvanUur, "hh:mm")

the somvanUur is 1,229166
Me!rek shows 05:30 while it should be 28:30

What am I doing wrong?

Thanks
JP
 
M

Marshall Barton

Jean-Paul said:
I have a table with 3 "time" fields:
1 starttime
1 stoptime
1 "worked time"

I created a querry to calculate the "worked time" (simple:
stoptime-starttime)

Finally I have to sum all "worked time"s together
I do this with following SQL:

sql = "SELECT Sum(Uren.gewerkt) AS SomVanUur FROM Uren WHERE
Uren.Datum > #" & Format(Forms![Uur_overzicht]!Start_dat, "DD/MM/YYYY")
& "# And Uren.Datum < #" & Format(Forms![Uur_overzicht]!Stop_dat,
"DD/MM/YYYY") & "# ;"
Set kost = db.OpenRecordset(sql)

Then I enter the value in an entryfield:

Me!rek = Format(kost!somvanUur, "hh:mm")

the somvanUur is 1,229166
Me!rek shows 05:30 while it should be 28:30

What am I doing wrong?


You're trying to format a duration as a (date/) time. That
value is actually the date 31 Dec 1899 05:30

You should look into using the builtin date/time function
subh as DateDiff to do the date/time difference in a a basic
unit such as minutes.

Until you figure that out, you can munge your current "time"
value by using this kinf of hokey expression:

Int(somvanUur * 24) & Format(somvanUur, ":nn")
 
J

Jean-Paul

Marshall said:
Jean-Paul said:
I have a table with 3 "time" fields:
1 starttime
1 stoptime
1 "worked time"

I created a querry to calculate the "worked time" (simple:
stoptime-starttime)

Finally I have to sum all "worked time"s together
I do this with following SQL:

sql = "SELECT Sum(Uren.gewerkt) AS SomVanUur FROM Uren WHERE
Uren.Datum > #" & Format(Forms![Uur_overzicht]!Start_dat, "DD/MM/YYYY")
& "# And Uren.Datum < #" & Format(Forms![Uur_overzicht]!Stop_dat,
"DD/MM/YYYY") & "# ;"
Set kost = db.OpenRecordset(sql)

Then I enter the value in an entryfield:

Me!rek = Format(kost!somvanUur, "hh:mm")

the somvanUur is 1,229166
Me!rek shows 05:30 while it should be 28:30

What am I doing wrong?


You're trying to format a duration as a (date/) time. That
value is actually the date 31 Dec 1899 05:30

You should look into using the builtin date/time function
subh as DateDiff to do the date/time difference in a a basic
unit such as minutes.

Until you figure that out, you can munge your current "time"
value by using this kinf of hokey expression:

Int(somvanUur * 24) & Format(somvanUur, ":nn")
OK... problem solved!
Thanks
 

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

Similar Threads


Top