Board index » delphi » Time and date problem.

Time and date problem.

Can anyone help me with the following problem ?

I am trying to write a small programme to forecast the time
and date a production order will be completed.
I calculate the total seconds as follows :

Order quantity * cycle time = Total seconds. (no problem)

If I have an order quantity of 1000000 and a cycle time
of 30 seconds the result = 30000000 seconds. This I can
calculate to 347 days, 5 hours and 20 min to complete
the order. My problem is, how do I add this value to the
current date and time in order to display a forecast of
date and time the order will be completed.

In return for your valuable assistance, all I can offer
is a copy of the programme, once it's finished.

Thanks. Tony H.
E-mail ya...@iafrica.com

 

Re:Time and date problem.


Take your result and divide it by 86400 (60seconds * 60 minutes * 24 hours)
and then add it to your current date/time.

Hope this helps.

Michael

A Hilton <ya...@iafrica.com> wrote in article
<36BA855C.6...@iafrica.com>...

Quote
> Can anyone help me with the following problem ?

> I am trying to write a small programme to forecast the time
> and date a production order will be completed.
> I calculate the total seconds as follows :

> Order quantity * cycle time = Total seconds. (no problem)

> If I have an order quantity of 1000000 and a cycle time
> of 30 seconds the result = 30000000 seconds. This I can
> calculate to 347 days, 5 hours and 20 min to complete
> the order. My problem is, how do I add this value to the
> current date and time in order to display a forecast of
> date and time the order will be completed.

> In return for your valuable assistance, all I can offer
> is a copy of the programme, once it's finished.

> Thanks. Tony H.
> E-mail ya...@iafrica.com

Re:Time and date problem.


Quote
On Thu, 04 Feb 1999 21:45:00 -0800, A Hilton <ya...@iafrica.com> wrote:
>Can anyone help me with the following problem ?

>I am trying to write a small programme to forecast the time
>and date a production order will be completed.
>I calculate the total seconds as follows :

>Order quantity * cycle time = Total seconds. (no problem)

>If I have an order quantity of 1000000 and a cycle time
>of 30 seconds the result = 30000000 seconds. This I can
>calculate to 347 days, 5 hours and 20 min to complete
>the order. My problem is, how do I add this value to the
>current date and time in order to display a forecast of
>date and time the order will be completed.

>In return for your valuable assistance, all I can offer
>is a copy of the programme, once it's finished.

I believe you need to multiple your number of seconds (an Integer value)
times 0.00001157407 and then add the result to a TDateTime value. This
would yield a TDateTime value that is that many seconds into the future.

//////////////////////////////////////////////////////////////////////////
Steve Koterski                   "Writers have two main problems. One is
Technical Publications           writer's block, when the words won't come
INPRISE Corporation              at all, and the other is logorrhea, when
http://www.inprise.com/delphi    the words come so fast that they can
                                 hardly get to the wastebasket in time."
                                                    -- Cecelia Bartholomew

Re:Time and date problem.


Quote
A Hilton wrote:

> Can anyone help me with the following problem ?

> I am trying to write a small programme to forecast the time
> and date a production order will be completed.
> I calculate the total seconds as follows :

> Order quantity * cycle time = Total seconds. (no problem)

> My problem is, how do I add this value to the
> current date and time in order to display a forecast of
> date and time the order will be completed.

> Thanks. Tony H.
> E-mail ya...@iafrica.com

Look in the help file under TDateTime, they are stored as a Double
value, the whole part being the number of days since some date, and
fraction part being a percentage of the day (i.e. time).
Just add the nmber of days to the current date, and work out what the
time would be for the fractional part.

Cheers,
Matt.

Other Threads