last day of previous month? (1 Viewer)

deejay_totoro

Registered User.
Local time
Today, 16:14
Joined
May 29, 2003
Messages
169
Hello all,

I have an unusal problem concerning dates.

I have a button on a form that when clicked, sets a label to the the current date.

However, what I would really like it to do is set the date the the last day of the previous month. For example, if I clicked it today, it would set 31/08/2004.

Any help much appreciated!

Many thanks!

dj_T
 

ray705

Registered User.
Local time
Today, 11:14
Joined
Feb 3, 2003
Messages
45
Microsoft article Q210604 discusses calculating dates in various ways.
The one you want would be:
- The last day of the previous month:
DateSerial(Year(Date()), Month(Date()),0)
 

deejay_totoro

Registered User.
Local time
Today, 16:14
Joined
May 29, 2003
Messages
169
Great!

Great!

Thanks that helped lots!

Cheers,

dj_T
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:14
Joined
Jul 9, 2003
Messages
16,244
It would appear difficult to find the last day of a month because you would think that you would need to store the actual day because there are three, or four possibilities if you include leap years 28, 29, 30, 31.

The brilliant way it was explained to me was that you should look for the first day of the next month and take one day off. giving you the correct last day of the month every time.
 

Users who are viewing this thread

Top Bottom