home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / vms / 14244 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  4.9 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!ucbvax!VAXA.NEWCASTLE-POLY.AC.UK!CUU1
  2. From: CUU1@VAXA.NEWCASTLE-POLY.AC.UK (David Hardy)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Submitting Jobs for Last Day of Month
  5. Message-ID: <9208281055.AA28653@ucbvax.Berkeley.EDU>
  6. Date: 27 Aug 92 10:33:00 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 113
  11.  
  12. In message <1992Aug25.102008.28397@jupiter.sun.csd.unb.ca>,  Jane MacDonald
  13. (jmacdonald@mta.ca) writes:
  14.  
  15. > I am wondering if anyone has a nifty way to have jobs submit themselves for
  16.  the
  17. > last day of the month.  Thank-you.
  18. >
  19. > Jane MacDonald (jmacdonald@mta.ca)
  20. > Jr. Systems Programmer
  21. > Computing Services
  22. > Mount Allison University
  23. > Sackville, New Brunswick
  24. > Canada
  25.  
  26. I think the command procedure listed below my signature should provide the
  27. information required. The procedure is more verbose than is needed but it helps
  28. to show what is happening. The posting didn't specify whether the last day of
  29. this month or the last day of next month was wanted so the procedure does both
  30. - use the parts required. The procedure takes advantage of the F$CVTIME lexical
  31. function to do the hard work for it.
  32.  
  33. David
  34.  
  35. +-------------------------------------------+--------------------------------+
  36. | David Hardy                               |                                |
  37. | Computer Unit, University of Northumbria, | Electronic mail:               |
  38. | Northumberland Building, Ellison Place,   |          DAVID.HARDY@NPY.AC.UK |
  39. | Newcastle upon Tyne, NE1 8ST, U.K.        |                                |
  40. +-------------------------------------------+--------------------------------+
  41. |  I can't even remember what excuses people gave for their mistakes before  |
  42. |  there were computers                      --- Frank Clark, King Features  |
  43. +----------------------------------------------------------------------------+
  44.  
  45. $!    Procedure to display the last day of this and next month. This is an
  46. $!    illustration of the calculations involved and should be edited as
  47. $!    required by the application concerned.
  48. $!
  49. $!    As far as I am aware, this procedure works correctly but you use it
  50. $!    at your own risk.
  51. $!
  52. $!    ====================================================================
  53. $!
  54. $!    Get current date
  55. $!
  56. $    current_date = f$extract(0,11,f$time())
  57. $    write sys$output "Current date: ",current_date
  58. $!
  59. $!    Replace the first two characters of the date by '01' to get the first
  60. $!    of the month
  61. $!
  62. $    first_of_month = "01" + f$extract(2,9,current_date)
  63. $    write sys$output "First of current month: ",first_of_month
  64. $!
  65. $! ****** This section for getting the last date in *this* month *****
  66. $!
  67. $!    Determine a date in next month (any date will do). By adding 31 days
  68. $!    to the first of this month, we guarantee some date early in next month.
  69. $!    f$cvtime() does not put a leading blank if the day of the month is a
  70. $!    single digit so we'll put a '0' on the front if the date string is not
  71. $!    long enough.
  72. $!
  73. $    next_month = f$cvtime("''first_of_month'+31-00:00:00","absolute","date")
  74. $    if f$length(next_month) .lt. 11 then next_month = "0" + next_month
  75. $    write sys$output "Date in next month: ",next_month
  76. $!
  77. $!    Determine the first of next month by replacing the first two characters
  78. $!    of the date by '01'.
  79. $!
  80. $    first_of_next_month = "01" + f$extract(2,9,next_month)
  81. $    write sys$output "First of next month: ",first_of_next_month
  82. $!
  83. $!    The last date of this month is one day before the date we've just
  84. $!    determined so get f$cvtime() to back-step one day. This is the date
  85. $!    we've been looking for.
  86. $!
  87. $    last_of_month = f$cvtime("''first_of_next_month-1-00:00:00",-
  88.         "absolute","date")
  89. $    write sys$output "Last date in current month: ",last_of_month
  90. $!
  91. $! ****** This section for getting the last date in *next* month *****
  92. $!
  93. $!    Determine a date in the month after next (any date will do). By adding
  94. $!    62 days to the first of this month, we guarantee some date early in the
  95. $!    month after next. f$cvtime() does not put a leading blank if the day of
  96. $!    the month is a single digit so we'll put a '0' on the front if the date
  97. $!    string is not long enough.
  98. $!
  99. $    next_but_one_month = f$cvtime("''first_of_month'+62-00:00:00",-
  100.         "absolute","date")
  101. $    if f$length(next_but_one_month) .lt. 11 then -
  102.         next_but_one_month = "0" + next_but_one_month
  103. $    write sys$output "Date in next but one month: ",next_but_one_month
  104. $!
  105. $!    Determine the first of month after next by replacing the first two
  106. $!    characters of the date by '01'.
  107. $!
  108. $    first_of_next_but_one_month = "01" + f$extract(2,9,next_but_one_month)
  109. $    write sys$output "First of next but one month: ",-
  110.         first_of_next_but_one_month
  111. $!
  112. $!    The last date of next month is one day before the date we've just
  113. $!    determined so get f$cvtime() to back-step one day. This is the date
  114. $!    we've been looking for.
  115. $!
  116. $    last_of_next_month = -
  117.         f$cvtime("''first_of_next_but_one_month-1-00:00:00",-
  118.         "absolute","date")
  119. $    write sys$output "Last date in next month: ",last_of_next_month
  120. $!
  121. $!    All done
  122. $!
  123. $    exit
  124.  
  125.