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

Date Diff Function

17 views
Skip to first unread message

Allen

unread,
Aug 30, 2010, 2:26:32 PM8/30/10
to
The date diff function as you know truncates the results but if you
need to ID a median value after the fact and the
fractional amount is relevant, does anyone know if a fractional result
can be pulled from a date diff's results?

Thanks

JKPeck

unread,
Aug 30, 2010, 10:32:40 PM8/30/10
to

The tricky part of that is that some of the units of the difference
are variable length, so the precise meaning of the fractional part
would be hard to define. You can get down to days, though, as the
unit, so maybe that is close enough.
The alternative is to just consider years as 365.25 days (or a finer
adjustment if you really care about the 100 and 400 year exceptions)
and subtract the dates. It's the difference between being old enough
to drink and a statistical measure of age.

HTH,
Jon Peck
(designer of datediff)

Ben Pfaff

unread,
Aug 30, 2010, 11:19:55 PM8/30/10
to
JKPeck <jkp...@gmail.com> writes:

> On Aug 30, 12:26 pm, Allen <jazzg...@aol.com> wrote:
>> The date diff function as you know truncates the results but if you
>> need to ID a median value after the fact and the
>> fractional amount is relevant, does anyone know if a fractional result
>> can be pulled from a date diff's results?
>

> The tricky part of that is that some of the units of the difference
> are variable length, so the precise meaning of the fractional part
> would be hard to define. You can get down to days, though, as the
> unit, so maybe that is close enough.

To get the difference between dates in days, just calculate
(date2 - date1) / (60 * 60 * 24).
--
Ben Pfaff
http://benpfaff.org

fred....@lsc.gov.uk

unread,
Aug 31, 2010, 8:47:35 AM8/31/10
to
Can't you just rerun the datediff calculation and keep the fractional
part, in old languauge it would be

Comp diff_days=Ctime.days(Date2-Date1).

0 new messages