Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Feb 2001
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #2
    Star Lounger
    Join Date
    Nov 2001
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: last day of month (access 97 )

    This should do it for you:

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

    hth,
    Jack

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: last day of month (access 97 )

    > Date( ) - Day(Date( ) )

    Nice! Thanks.

  4. #4
    Lounger
    Join Date
    Feb 2001
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    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!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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