last date of the month

  • Thread starter Thread starter JIM.H.
  • Start date Start date
J

JIM.H.

Hello,
currentDateStr=Format(date(),"YYYYMM01") gives a string
first day of the current month, how can I get last day of
the month?
Jim.
 
Hello,
currentDateStr=Format(date(),"YYYYMM01") gives a string
first day of the current month, how can I get last day of
the month?
Jim.

The last day of the current month:

=DateSerial(Year(Date()),Month(Date())+1,0)
 
If I want to get the last day of previous month in
YYYYMMDD format, what should I do?
 
JIM.H. said:
If I want to get the last day of previous month in
YYYYMMDD format, what should I do?

Format(DateSerial(Year(Date()),Month(Date())+1,0), "yyyymmdd")
 
this gives current month, if I remove +1 will it be giving
previous month? I just want to make sure, at the end of
year will not be causing any trouble.
 
JIM.H. said:
this gives current month, if I remove +1 will it be giving
previous month? I just want to make sure, at the end of
year will not be causing any trouble.

The expression as provided returns the last day of the current month. The
end of the year? I'm not sure what you mean by that. In December it will
return 12/31/2004 and in January it will return 1/31/2005.

DateSerial is fully aware of all wrapping issues. It "knows" that when the
month number is greater than 12 it has to increment the year and when the
day is greater than the number of days in the month that it has to
increment the number for the month.
 
I am looking for the end of previous month, not current
month. How should I get it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top