Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!decvax!decwrl!ucbvax!YALE.ARPA!LEICHTER-JERRY From: LEICHTER-JERRY@YALE.ARPA.UUCP Newsgroups: mod.computers.vax Subject: Re: date/time arithmetic in vms Message-ID: <8607031245.AA07794@ucbvax.Berkeley.EDU> Date: Thu, 3-Jul-86 08:47:09 EDT Article-I.D.: ucbvax.8607031245.AA07794 Posted: Thu Jul 3 08:47:09 1986 Date-Received: Thu, 3-Jul-86 23:37:55 EDT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Organization: The ARPA Internet Lines: 28 Approved: info-vax@sri-kl.arpa If I want to compute a date (VAX quadword date form) that is 1 month from today - what is the best way? The quadword format is the one to work with; since it is a simple binary number - yes, I know it's a quadword - you can do arithmetic on it: a) Use $GETTIM to get the current time into quadword NOW. b) Now you need, in quadword DELTA, a delta time that represents "one month". Unfortunately, there is no notation for "plus one month" - only for "plus some number of days". So you'll need to compute the number of days in the current month ("30 days hath September, all the rest I don't remember", to quote Martin Minow) - call it dd - and convert the delta time "dd 00:00:00.00" into DELTA, again with $BINTIM. c) The value you want is NOW - DELTA. (It's "-" rather than "+" because delta times in quadword format are stored negated.) That leaves the problem of doing quadword arithmetic, something no HLL does directly. However, there is a library procedure - LIB$SUBX - to do exactly that. The quadword values themselves your HLL program will consider to be arrays of 2 longwords. There is an alternative approach: Rather than using $NUMTIM, use $ASCTIM. The ASCII string you get back isn't nearly as convenient for manipulation as the array $NUMTIM gives you, but you CAN convert it back with $BINTIM. -- Jerry -------