From: CUU1@VAXA.NEWCASTLE-POLY.AC.UK (David Hardy)
Newsgroups: comp.os.vms
Subject: Re: Submitting Jobs for Last Day of Month
Date: 27 Aug 92 10:33:00 GMT
Distribution: world
Organization: The Internet

In message <1992Aug25.102008.28397@jupiter.sun.csd.unb.ca>,  Jane MacDonald
(jmacdonald@mta.ca) writes:

> I am wondering if anyone has a nifty way to have jobs submit themselves for
 the
> last day of the month.  Thank-you.
>
> Jane MacDonald (jmacdonald@mta.ca)
> Jr. Systems Programmer
> Computing Services
> Mount Allison University
> Sackville, New Brunswick
> Canada

I think the command procedure listed below my signature should provide the
information required. The procedure is more verbose than is needed but it helps
to show what is happening. The posting didn't specify whether the last day of
this month or the last day of next month was wanted so the procedure does both
- use the parts required. The procedure takes advantage of the F$CVTIME lexical
function to do the hard work for it.

David

+-------------------------------------------+--------------------------------+
| David Hardy                               |                                |
| Computer Unit, University of Northumbria, | Electronic mail:               |
| Northumberland Building, Ellison Place,   |          DAVID.HARDY@NPY.AC.UK |
| Newcastle upon Tyne, NE1 8ST, U.K.        |                                |
+-------------------------------------------+--------------------------------+
|  I can't even remember what excuses people gave for their mistakes before  |
|  there were computers                      --- Frank Clark, King Features  |
+----------------------------------------------------------------------------+

$!	Procedure to display the last day of this and next month. This is an
$!	illustration of the calculations involved and should be edited as
$!	required by the application concerned.
$!
$!	As far as I am aware, this procedure works correctly but you use it
$!	at your own risk.
$!
$!	====================================================================
$!
$!	Get current date
$!
$	current_date = f$extract(0,11,f$time())
$	write sys$output "Current date: ",current_date
$!
$!	Replace the first two characters of the date by '01' to get the first
$!	of the month
$!
$	first_of_month = "01" + f$extract(2,9,current_date)
$	write sys$output "First of current month: ",first_of_month
$!
$! ****** This section for getting the last date in *this* month *****
$!
$!	Determine a date in next month (any date will do). By adding 31 days
$!	to the first of this month, we guarantee some date early in next month.
$!	f$cvtime() does not put a leading blank if the day of the month is a
$!	single digit so we'll put a '0' on the front if the date string is not
$!	long enough.
$!
$	next_month = f$cvtime("''first_of_month'+31-00:00:00","absolute","date")
$	if f$length(next_month) .lt. 11 then next_month = "0" + next_month
$	write sys$output "Date in next month: ",next_month
$!
$!	Determine the first of next month by replacing the first two characters
$!	of the date by '01'.
$!
$	first_of_next_month = "01" + f$extract(2,9,next_month)
$	write sys$output "First of next month: ",first_of_next_month
$!
$!	The last date of this month is one day before the date we've just
$!	determined so get f$cvtime() to back-step one day. This is the date
$!	we've been looking for.
$!
$	last_of_month = f$cvtime("''first_of_next_month-1-00:00:00",-
		"absolute","date")
$	write sys$output "Last date in current month: ",last_of_month
$!
$! ****** This section for getting the last date in *next* month *****
$!
$!	Determine a date in the month after next (any date will do). By adding
$!	62 days to the first of this month, we guarantee some date early in the
$!	month after next. f$cvtime() does not put a leading blank if the day of
$!	the month is a single digit so we'll put a '0' on the front if the date
$!	string is not long enough.
$!
$	next_but_one_month = f$cvtime("''first_of_month'+62-00:00:00",-
		"absolute","date")
$	if f$length(next_but_one_month) .lt. 11 then -
		next_but_one_month = "0" + next_but_one_month
$	write sys$output "Date in next but one month: ",next_but_one_month
$!
$!	Determine the first of month after next by replacing the first two
$!	characters of the date by '01'.
$!
$	first_of_next_but_one_month = "01" + f$extract(2,9,next_but_one_month)
$	write sys$output "First of next but one month: ",-
		first_of_next_but_one_month
$!
$!	The last date of next month is one day before the date we've just
$!	determined so get f$cvtime() to back-step one day. This is the date
$!	we've been looking for.
$!
$	last_of_next_month = -
		f$cvtime("''first_of_next_but_one_month-1-00:00:00",-
		"absolute","date")
$	write sys$output "Last date in next month: ",last_of_next_month
$!
$!	All done
$!
$	exit