View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Papa Jonah Papa Jonah is offline
external usenet poster
 
Posts: 148
Default Identify last date of a specific month

Keith,
I tried the worksheet function and have interesting results. For the dates
in Dec 08, it worked well in that it identified 12/31/08 as the last date of
December.
However, for all the other dates, it added a year. For example June 09
dates resulted in 6/30/10.
Maybe I buggered your formula. My dates are in column H and this is how I
substituted to accomodate.
=DATE(ROUND(((YEAR(H3)*12+MONTH(H3)+1)/12),0),MOD((YEAR(H3)*12+MONTH(H3)+1),12),1)-1


"ker_01" wrote:

In VBA or via formula, I think your easiest option will be to find the first
date of the subsequent month, and subtract 1.

Formula Example:
Cell A1 = Dec 2008
Cell B1 =
DATE(ROUND(((YEAR(A1)*12+MONTH(A1)+1)/12),0),MOD((YEAR(A1)*12+MONTH(A1)+1),12),1)-1

Code example:
Sub LastMonthDay()
OrgDate = Sheet1.Range("A1").Value
NextMonthStartDate = DateSerial(Year(OrgDate), Month(OrgDate), 1)

ActualLastDay = NextMonthStartDate - 1
End Sub


HTH,
Keith

"Papa Jonah" wrote:

I have a spreadsheet that identifies months in a column. The format is:
December-08 (for December 2008).
I need to take that and identify that 12/31/2008 is the last date in that
month. I need to do this in order to calculate the number of days between
that date and today.
TIA,
Papa