T.R | Title | User | Personal Name | Date | Lines |
---|
1883.1 | Try this | VMSDEV::HALLYB | Fish have no concept of fire | Mon Jul 25 1994 09:24 | 61 |
| Convert the dates to Julian date format and subtract the smaller from
the larger.
The following routines can be used to convert between Julian and
standard date format. They assume 32-bit longs and would need to
be adapted if you are bulding 16-bit PC applications.
John
unsigned long tojul(unsigned long x) /* YYMMDD --> Julian date */
{
float day, month, year, igreg, julday, ja, jy, jm;
igreg = (15 + 31 * (10 + 12 * 1582)); /* Date of adoption of Greg. Cal. */
year = 1900 + (int)(x / 10000);
if (year < 0.0) year++;
month = (x/100) - 100 * (x/10000);
day = x % 100;
if (month > 2.0) {jy = year; jm = month + 1.0;}
else {jy = year - 1; jm = month + 13.;}
julday = ((unsigned long)(365.250 * jy));
julday += ((unsigned long)(30.6001 * jm));
julday += day + 1720995;
if ((day + 31 * (month + 12 * year)) >= igreg)
{
ja = ((unsigned long)(.01 * jy));
julday += (2.0 - ja);
julday += (.25 * ja);
}
return ((unsigned long)(julday));
}
unsigned long toyymmdd(unsigned long x) /* Julian date --> YYMMDD */
{
long igreg, jalpha, ja, jb, jc, jd, je, id, mm, yy, q;
igreg = 2299161;
if (x >= igreg)
{
jalpha = (((x - 1867216) - .25) / 36524.25);
q = .25 * jalpha;
ja = x + 1 + jalpha - q;
}
else ja = x;
jb = ja + 1524;
jc = 6680 + ((jb - 2439870) - 122.1) / 365.25;
q = .25 * jc;
jd = 365 * jc + q;
je = (jb - jd) / 30.6001;
q = 30.6001 * je;
id = jb - jd - q;
mm = je - 1;
if (mm > 12) mm = mm - 12;
yy = jc -4715;
if (mm > 2) yy--;
if (yy <= 0) yy--;
yy = yy - 1900;
return ((unsigned long)((yy * 10000) + (mm * 100) + id));
}
|
1883.2 | if doing it is more important than the formula | AUSSIE::GARSON | achtentachtig kacheltjes | Mon Jul 25 1994 09:48 | 15 |
| re .0
If the dates are 17-NOV-1858 or later
Other approaches are:
Convert both dates to a day number using LIB$DAY and then subtract the
results.
*or*
If the number of days is <= 9999 then convert both dates to VMS
absolute date/time format with SYS$BINTIM, then subtract with
LIB$SUB_TIMES, then convert back to human readable format with
SYS$ASCTIM.
|
1883.3 | Thanks for help! | SUOSWS::GEISELHART | | Tue Jul 26 1994 03:15 | 3 |
| Thanks for replies, I will try it out this evening.
Bianca.
|
1883.4 | DELTA_DAYS.COM | ULYSSE::FINKA | | Tue Jul 26 1994 05:19 | 18 |
| $! DELTA_DAYS.COM J. FINKA Nov 1990
$! assume p1 <= p2 and delta < 9995
$ p1 = f$cvtime(p1,"absolute","date")
$ p2 = f$cvtime(p2,"absolute","date")
$ y1 = f$integer(f$cvtime(p1,,"year"))
$ y2 = f$integer(f$cvtime(p2,,"year"))
$ m1 = f$integer(f$cvtime(p1,,"month"))
$ m2 = f$integer(f$cvtime(p2,,"month"))
$ d1 = f$integer(f$cvtime(p1,,"day"))
$ d2 = f$integer(f$cvtime(p2,,"day"))
$ y = (36525 * (y2 - y1) + 3044 * (m2 - m1)) / 100 + d2 - d1
$ i = 0
$ l: x = y + i
$ i = - i
$ if i .ge. 0 then i = i + 1
$ q = f$cvtime(p1 + "+" + f$string(x) + "-","absolute","date")
$ if q .nes. p2 then goto l
$ write sys$output "Delta days : ", x
|
1883.5 | | HANNAH::OSMAN | see HANNAH::IGLOO$:[OSMAN]ERIC.VT240 | Tue Jul 26 1994 15:43 | 14 |
|
Try this right from character cell notes:
Notes> spawn @hannah::igloo$:[osman.comfiles]subdat 1-jul-1994 1-apr-1993
And of course this one(!):
Notes> spawn @hannah::igloo$:[osman.comfiles]subdat 11-jul-1994 1-jan-2000
/Eric
|
1883.6 | re. .-1 | OINOH::KOSTAS | He is great who confers the most benefits. | Wed Jul 27 1994 11:35 | 15 |
| re. .-1
Hi Eric,
why do I get the same answer for two different dates?
i.e.,
spawn @hannah::igloo$:[osman.comfiles]subdat 20-Nov-1957 27-jul-1994
spawn @hannah::igloo$:[osman.comfiles]subdat 20-Nov-1963 27-jul-1994
both give:
9999 days, 23:59:59.99
/k
|
1883.7 | | CSC32::D_DERAMO | Dan D'Eramo, Customer Support Center | Wed Jul 27 1994 11:48 | 7 |
| The VMS delta time format does not go to 10,000 days or
beyond. It is limited to nnnn hh:mm:ss.cc, the maximum
being 9999 days 23 hours 59 minutes 59.99 seconds.
Reply .2 mentions the restriction.
Dan
|