Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2003
    Posts
    280

    Unanswered: How do I retrieved the last day of the month?

    For example, let say currently it July 2003 and I want to pull up or get the value of the last day for June 2003. This validate if the days in my data has gone pass the last day of June 2003, which the Access won't accept when appending data to a table.

    Last day of June 2003 is the 31. In some of the data show June 32, 2003, which is unacceptable for Access to accept it. These data was scan from a scantron paper to a table(from people handwriting), so I have no control over this. I can only validate the data before it goes into the table with the date/time fields. Hope this is understandable to read....

  2. #2
    Join Date
    May 2002
    Location
    London
    Posts
    87
    You could try Isdate(<str>) as a quick solution. I checked and
    Isdate("June 30, 2003") returns TRUE whilst Isdate("June 32, 2003") is FALSE.

  3. #3
    Join Date
    Apr 2003
    Posts
    280
    hmm, i never thought of that. Thanks!

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    and going back to your original question: you can get the last day of the previous month from
    Code:
    EndPriorMonth = dateadd("d", -1, DateSerial(year(now()), month(now()), 1))
    izy

  5. #5
    Join Date
    Apr 2003
    Posts
    280
    Originally posted by izyrider
    and going back to your original question: you can get the last day of the previous month from
    Code:
    EndPriorMonth = dateadd("d", -1, DateSerial(year(now()), month(now()), 1))
    izy
    Wow, neat code. I have test it out and it work. I always use DateFormat when doing some type of date retrieval. Anyways, can you explain to me how this code works, like how did it retrieval the previous month and the last day of the previous?

    I have try messing around with the value of the code and I don't see how this code retrieve the previous month and the last day of the previous. I would love to understand this code on how it works.

    Thanks!

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    it's tough to guess the end of the month (28, 29, 30, 31 ??), but the first of the month is easy (it's the 1st !!!).

    the code is building a date from current year, current month, day = 1
    and then subtracting (-1) one ("d") day.

    izy

  7. #7
    Join Date
    Apr 2003
    Posts
    280
    ohhhhh, I see now.

Posting Permissions

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