From: CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 22-FEB-1989 22:18 To: MRGATE::"ARISIA::EVERHART" Subj: Re: Month Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 22 FEB 89 16:01:04 PDT Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Wed, 22 Feb 89 15:35:23 PST Received: by ucbvax.Berkeley.EDU (5.61/1.34) id AA21155; Wed, 22 Feb 89 15:13:19 -0800 Received: from USENET by ucbvax.Berkeley.EDU with netnews for info-vax@kl.sri.com (info-vax@kl.sri.com) (contact usenet@ucbvax.Berkeley.EDU if you have questions) Date: 21 Feb 89 15:30:02 GMT From: munnari!vuwcomp!wnv!gpwd!gpwrmdh@uunet.uu.net (Martin D. Hunt) Organization: Government Printing Office, Wellington, New Zealand Subject: Re: Month Message-Id: <295@gp.govt.nz> References: <246@gp.govt.nz>, <603498985.0.TOM@MARS> Sender: info-vax-request@kl.sri.com To: info-vax@kl.sri.com In article <603498985.0.TOM@MARS>, TOM%Irving@VX1.GBA.NYU.EDU (Tom C Crowley) writes: > Date: 27 Jan 89 05:30:24 GMT > From: munnari!vuwcomp!wnv!gpwd!gpwrmdh@uunet.uu.net (Martin D. Hunt) > Organization: Government Printing Office, Wellington, New Zealand > Subject: Re: Month > > In article <8901221116.AA12223@ucbvax.Berkeley.EDU>, Brian.T.Carcich@CUSPIF.TN.CORNELL.EDU writes: > >> > >>Just a quick question - is there ANY easy, lexical-like way to get the > >>next month from the current? > >> > > > > How about this: > > > > $ write sys$output f$cvtime(f$extract(2,5,f$time())+"+31-","absolute","month") > > or > > $ nextmon= f$cvtime(f$extract(2,5,f$time())+"+31-","absolute","month") > > > > Yuk! There is a simple call which only needs one lexical function call: > > $ nextmon = f$cvtime ("+31-", "absolute", "month") > > I can't understand why the above example wastes time mucking around with > f$extract, when f$cvtime does it all for you anyway. > > Martin D. Hunt > Government Printing Office > Wellington > New Zealand > > Wrong. Think what would happen with your solution on the 31st of January. > or March. or June..... > > What I ended up doing is using f$cvtime to get the year and month fields, > prepending a "28-", then asking f$cvtime for the month field 5 days past > that constructed date. very messy, but no loopholes I can see. Any better > ideas?? > Yes, the fact that my solution falls over at certain times of the month was pointed out to me by my fellow-worker Don Stokes and his solution was also posted. The solution is as follows: $ Next_month = f$cvtime ("1-+31-","absolute","month") This uses a combination time 1- indicates beginning of the current month, +31- means add 31 days to the beginning of the month. It only involves one lexical call. I haven't worked out where you are putting the "28-" - this string does not appear in your solution. Martin D. Hunt