Date Math

Kenneth Brody kenbrody at bestweb.net
Tue May 16 17:53:57 PDT 2006


Quoting Fairlight (Tue, 16 May 2006 14:35:33 -0400):

> Confusious (Kenneth Brody) say:
> >
> > But, given that filePro already has date math and time math, all you
> > need to do is subtract the two dates, multiply by 24 (to get hours),
> > and add the difference of the times.
>
> I don't see how this:
>
> >     deltatime = (date2-date1)*"24" + (time2-time1)
>
> accounts for an earlier time2 than time1.  7 - 11 == -4.  I don't think
> you want to -subtract- four hours.

Why not?

What's (16-May-2006 07:00) minus (14-May-2006 11:00)?

date2-date1 = 2 days.
time2-time1 = negative 4 hours.

deltatime = 44 hours.  (That is, 4 hours short of 2 days, or "2 days
minus 4 hours".)

> That's why I did it my way, way back.
>
> What obvious and simple fact am I overlooking?

See previous example.

If the start and end times are the same time-of-day, then you have
an exact multiple of 24 hours in delta_date.

If the end time is later in the day than the start time, then you
add that number of hours to the number of days in delta_date.  (That
is, it's a certain number of days _plus_ some number of hours.)

If the end time is earlier in the day than the start time, then you
want to subtract that many hours from the delta_date.

[...]
> Now, what's the part of the reality that I'm being blind to?  It's gotta
> be dead simple, but I'm not getting it.

Is it time for your Homer Simpson impersonation?  :-)

[ referring to a "UNIXTIME()" function ]
> > While there might be use for such a function, there is no need for it
> > here.
>
> I've had use for such function many times.  I wish it had gone in with
> the PID() and PPID() functions so we could finally easily make TRULY
> unique identifiers for transactions.  That combination key is one of
> the best ways to get unique identifier, and it's unavailable unless
> you use USER or SYSTEM.

Well, you can always get the time of day by storing @TM in a numeric
field.  (And then multiply by 3600 to get it in seconds.)

[...]

--
KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list