Re: How to calculate end of the month.

classic Classic list List threaded Threaded
1 message Options
Open this post in threaded view
Report Content as Inappropriate

Re: How to calculate end of the month.

Nana Nadine
I suggest you should use the date and time wizard. It is found under compute. If you have a date variable you should be able to extract that day with any type of referential.

Richard Ristow <[hidden email]> wrote:  Last date of the month 5, or 11, or a chosen number of months from the
current one - Jim Marks posted a nice solution. Here's a variation
(code not tested):

At 12:47 PM 6/14/2006, Marks, Jim wrote:

>Here is a solution for 11 months out using SPSS date variables.

Still with SPSS date variables -

First, go *12* months out, instead of 11. That's not because 12 months
is a year; it's because 12 months is one more than you want:

*** month and year, adjusted for change of year (month gt 12).
COMPUTE month_12 =xdate.month(date)+12.
COMPUTE year_12 = xdate.year(date).
if month_12 GT 12 year_12 = year_12+1.
IF month_12 gt 12 month_12 = month_12-12.

(Of course, for exactly 12, the logic is easier, but I'm leaving it

Second, the 'cute' part: the last day of the month 11 months out, is
the day before the first day of the month 12 months out:

COMPUTE end_date = date.mdy(month_12,1,year_12)-TIME.DAYS(1).

Nadine Nana
404 805 6209
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around