Thread: last day of month (access 97 )

1. last day of month (access 97 )

I have a routine that is performed the first business day of the month. (which is not always the first day of the month) What I need to put into the table though is the last date of the prior month. I have been playing with different date functions but I can't seem to figure this out.
Any Ideas?

2. Re: last day of month (access 97 )

This should do it for you:

LastDayOfPreviousMonth = DateSerial(Year(Date()), Month(Date()),0)

hth,
Jack

3. Re: last day of month (access 97 )

> Date( ) - Day(Date( ) )

Nice! Thanks.

4. Re: last day of month (access 97 )

I used this function and It was perfect. Thanks Cathy Knoll <img src=/S/joy.gif border=0 alt=joy width=23 height=23>

5. Re: last day of month (access 97 )

You wrote:
>>I have a routine that is performed the first business day of the month. (which is not always the first day of the month) What I need to put into the table though is the last date of the prior month. I have been playing with different date functions but I can't seem to figure this out.
Any Ideas? <<

First of all, I hope you are not storing the last day of the prior month in a table. You can always calculate this.

To find the last day of a month, we can use the feature in Access that the "0" day of any month is the same as the last day of the prior month. So, all we have to do is subtract the current day of the month from the current date, using this equation:
<pre> Date() - Day(Date())</pre>

The Date( ) function returns today's date; the Day( ) function returns just the day of the month for the date specified (in this case, today). Normally, we would then use the DateDiff( ) function to add/subtract from dates. However, a date datatype is actually a scaled integer which holds a total number of days to the left of the decimal, and keeps the time as fractions of a day to the right of the decimal. This means if we want to add/subtract a certain number of days from any date, we can just directly use regular math operators against the date field. This is quicker, and much easier to remember!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•