Results 1 to 5 of 5

Thread: DateDiff Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Carolina, Puerto Rico, USA
    Posts
    227

    DateDiff Problem

    Hi.

    I want to determine how long a month is, but when I do this

    Code:
    strLeft = 8/31/2003
    varMonthLength = DateDiff("d", CDate(strLeft), DateAdd("m", 1, CDate(strLeft)))
    I get 30 instead of 31, what can cause that to happen?, and how I can get the accurate number?

    Thanks in advance.
    NievesJ

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Location
    Carolina, Puerto Rico, USA
    Posts
    227
    Um, hehehe, my mistake, I know what is happening
    NievesJ

  3. #3
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Tell us .. what is happening!!!

  4. #4
    Lively Member
    Join Date
    Oct 2002
    Location
    Plantation, FL (USA)
    Posts
    66
    Try this:

    VB Code:
    1. strLeft = "8/31/2003"
    2. varMonthLength  = Day(DateSerial(Year(CDate(strLeft)), Month(CDate(strLeft)) + 1, 0))

    Diego.

  5. #5
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    It is just because september (month number 9) has only 30 days. If you add 1 month to 31-8-2003 you get 30-9-2003

Posting Permissions

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



Click Here to Expand Forum to Full Width