Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread DBISAM Time problem
Tue, Oct 21 2008 6:50 AMPermanent Link

"Carlos"
Hi
I have to memorize the durations hours a mint of an event and save in a
field of type TIME.
Then I must add all the hours recorded in another table.
How can I do?
I tried to use in the second table format FLOAT but I have difficulties to
successfully add the hours / minutes and store them.
Help !

Thanks

Carlos

Tue, Oct 21 2008 7:42 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Carlos


TIME is the wrong type to use to store duration. Two reasons:

1. you would have to be totally, utterly and absolutely certain that the hours portion would never be more then 24 (I think time is stored as milliseconds past midnight)
2. you can't add two times together and get a meaningful result

What you need to do is either store a start and stop time so you can calculate the duration of the event or store hours and minutes separately.

You could manage something by casting the TIME column splitting out the hours and minutes but it would be a nasty piece of sql.


Roy Lambert
Tue, Oct 21 2008 7:47 AMPermanent Link

Rolf Frei

eicom GmbH

Time is the wrong fieldtype for your need. I would do a Integer Field and
save the sconds of duration. So you can just fine calculate with it.

Regards
Rolf

"Carlos" <carlos@noemail.com> schrieb im Newsbeitrag
news:6589BEF9-22D8-441E-A1DF-74C0CD071A6D@news.elevatesoft.com...
> Hi
> I have to memorize the durations hours a mint of an event and save in a
> field of type TIME.
> Then I must add all the hours recorded in another table.
> How can I do?
> I tried to use in the second table format FLOAT but I have difficulties to
> successfully add the hours / minutes and store them.
> Help !
>
> Thanks
>
> Carlos
>

Tue, Oct 21 2008 9:07 AMPermanent Link

"Carlos"
Specifically:

Should I register the duration of a flight in hours and minutes.
For example, two hours and fifteen minutes are 2:15

I must add these hours to a total flight hours
to turn a timetable.

1st table three record

First flight: 2:15
Second: 1:20
Third: 1:10

2ns table: total record

Total hours: 2:15 + 1:20 + 1:10 = 4:45

Thank you

Carlos

Tue, Oct 21 2008 9:58 AMPermanent Link

Rolf Frei

eicom GmbH

You can do that with minutes just simple:

1st table three record

First flight: 135
Second: 80
Third: 70

2ns table: total record in minutes

Total minutes: 135 + 80 + 70 =  285 Minutes = 285 div 60 =  4 Hours  / 285
mod 60 = 45 Minutes =  4:45

For display you can just simple calculate the hours and minutes like in the
sample above.

Regards
Rolf


"Carlos" <carlos@noemail.com> schrieb im Newsbeitrag
news:72538364-96A1-430E-A432-B8BC02D659DC@news.elevatesoft.com...
> Specifically:
>
> Should I register the duration of a flight in hours and minutes.
> For example, two hours and fifteen minutes are 2:15
>
> I must add these hours to a total flight hours
> to turn a timetable.
>
> 1st table three record
>
> First flight: 2:15
> Second: 1:20
> Third: 1:10
>
> 2ns table: total record
>
> Total hours: 2:15 + 1:20 + 1:10 = 4:45
>
> Thank you
>
> Carlos
>

Tue, Oct 21 2008 10:03 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Carlos


Assuming

1. you're only bothered about to the nearest minute
2. you're going to be using sql not Dephi

As Rolf suggests hold the data as a single integer - but minutes rather than seconds

To get the total

SELECT TRUNC(SUM(duration) / 60) AS HOURS , (duration - 60*(TRUNC(SUM(duration) / 60))) AS MINUTES FROM timetable

for a single flight you just don't use SUM

Roy Lambert [Team Elevate]
Tue, Oct 21 2008 10:18 AMPermanent Link

"Carlos"
I thank you very much for the answers !!

C.

Image