Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    12

    Unanswered: Last day of month

    I know this has to be simple but I don't know the answer. Is there a simple formula for returning the the last day of the month for a given month? I'm using Access 2000.

    Thanks!
    Cheri

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    It is much easier to find the beginning of the month and then subtract one day using the DateAdd function. How are the month and year going to be determined? Are you trying to get the last day of the current month? If so try:

    DateAdd("d",-1,Eval("#" & Month(Date())+1 & "/1/" & Year(Date()) & "#"))

    It might look bad, but all I am doing is adding 1 to the current month, picking the first day or that month, then the DateAdd subtracts one day.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Here's another way; it may look more daunting but here's what I consider to be the correct way of doing it
    Code:
    Dim firstDayOfMonth As Date
    Dim lastDayOfMonth As Date
    Dim allTogetherNow As Date
    
    firstDayOfMonth = DateAdd("mm", DateDiff("mm", 0, Now()), 0)
    
    lastDayOfMonth = DateAdd("dd", -1, DateAdd("mm", 1, firstDayOfMonth))
    
    AllTogetherNow = DateAdd("dd", -1, DateAdd("mm", 1, DateAdd("mm", DateDiff("mm", 0, Now()), 0)))
    George
    Home | Blog

Posting Permissions

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