Operating System - OpenVMS
cancel
Showing results for
Search instead for
Did you mean:

## How to get next month's end date?

Occasional Visitor

## How to get next month's end date?

Using DCL, how do I determine the last day of next month? I have found answers to determining the first of next month as well as the last day of the current month. However, I cannot find a solution to returning next month's ending date.
5 REPLIES 5
Honored Contributor

## Re: How to get next month's end date?

I usually don't bother with the fancy stuff, and simply have the job(s) submitted and run daily.

Here's some fancy stuff:

http://h71000.www7.hp.com/wizard/wiz_6046.html

Here's something more on target, from an old comp.os.vms posting:

\$ FirstOfLastMonth = "1-" +
f\$extract(3,8,f\$cvtime("1---1-","absolute","date"))
\$ LastOfLastMonth = f\$cvtime("1---1-","absolute","date")
\$ FirstOfThisMonth = f\$cvtime("1--","absolute","date")
\$ LastOfThisMonth = -
f\$cvtime("1-" +
f\$extract(2,8,f\$cvtime("28--+4-","absolute","date")) -
+ "-1-","absolute","date")
\$ FirstOfNextMonth = "1-" +
f\$extract(2,8,f\$cvtime("28--+4-","absolute","date"))
\$ LastOfNextMonth = -
f\$cvtime( "1-" +
f\$extract(2,8,f\$cvtime("28--+35-","absolute","date")) -
+ "-1-","absolute","date")
Honored Contributor

## Re: How to get next month's end date?

John,

Basically, the last day of next month is the day before the first day of the second month (with allowances for year overflow).

Hence:

Current First day of second month Last day of next month
11/30/2009 1/1/2010 12/31/2009
1/1/2010 3/1/2010 2/28/2009

One important part of this approach is that it deals with leap years automatically.

The F\$CVTIME function is used to convert dates and times.

- Bob Gezelter, http://www.rlgsc.com

Occasional Visitor

## Re: How to get next month's end date?

Thank you for the response. This is exactly what I need.
Occasional Visitor

## Re: How to get next month's end date?

The question was answered.
Respected Contributor

## Re: How to get next month's end date?

"The question was answered."

... and yet no points were assigned.