Calc Last day of the month from any date

  • Thread starter Thread starter Krisse
  • Start date Start date
K

Krisse

I want to calculate the last day of the month for any
given date.

For example I want the result to be 09/30/2003 with data
that reads 09/18/2003.

I can do it in a round about way, but I thought there may
be function I could use instead, although I couldn't fine
one.

Thanks!
 
I want to calculate the last day of the month for any
given date.

For example I want the result to be 09/30/2003 with data
that reads 09/18/2003.

I can do it in a round about way, but I thought there may
be function I could use instead, although I couldn't fine
one.

You can use the "DateSerial()" function:

DateSerial(Year([MyDate]), Month([MyDate])+1, 0)
 
I want to calculate the last day of the month for any
given date.

For example I want the result to be 09/30/2003 with data
that reads 09/18/2003.

I can do it in a round about way, but I thought there may
be function I could use instead, although I couldn't fine
one.

There's a trick you can use, taking advantage of the flexibility of
the DateSerial function:

DateSerial(Year([givendate]), Month([givendate]) + 1, 0)

This will give you the zeroth day of the NEXT month - which magically
corresponds to the last day of the current month.
 
Thanks John!
-----Original Message-----
I want to calculate the last day of the month for any
given date.

For example I want the result to be 09/30/2003 with data
that reads 09/18/2003.

I can do it in a round about way, but I thought there may
be function I could use instead, although I couldn't fine
one.

There's a trick you can use, taking advantage of the flexibility of
the DateSerial function:

DateSerial(Year([givendate]), Month([givendate]) + 1, 0)

This will give you the zeroth day of the NEXT month - which magically
corresponds to the last day of the current month.


.
 
Thanks Bruce!

-----Original Message-----
I want to calculate the last day of the month for any
given date.

For example I want the result to be 09/30/2003 with data
that reads 09/18/2003.

I can do it in a round about way, but I thought there may
be function I could use instead, although I couldn't fine
one.

You can use the "DateSerial()" function:

DateSerial(Year([MyDate]), Month([MyDate])+1, 0)

--
Bruce M. Thompson
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)within the newsgroups so that all might benefit.<<


.
 
I wonder why you asked the same question again while you had 3 responses all
pointing to the correct solution.

In fact, John Vinson was one of the respondents in the previous thread.

If you have any question about the replies, you should reply in the same
thread rather than wasting repondents time giving you the SAME answer.

Please read the Netiquette for correct use of the newsgroups:

http://www.mvps.org/access/netiquette.htm

HTH
Van T. Dinh
MVP (Access)
 
Back
Top