Results 1 to 5 of 5
  1. #1
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108

    DateDiff() returns value 0?

    I'm trying to calculate the number of dates between StartRange and EndRange
    However, when I use DateDiff() , I get return value 0

    Eg, 1/11/2015 to 1/11/2015
    Message box will display value "0"

    Any ideas where went wrong ?
    Thanks in advance

    Code:
    StartRange = CDate(cboStartRange)
        EndRange = CDate(cboEndRange)
        UpdateSQL = "Update Setting Set Start_Range = '" & StartRange & "', End_Range = '" & EndRange & "' Where Type = 'SUMMARY_RANGE'"
        
        
        'Calculate MONTHS
        Dim intmonths As Integer
        
       ' intmonths = DateDiff("m", StartRange, EndRange) + 1
        intmonths = DateDiff("m", StartRange, EndRange)
        'intmonths = DateDiff("m", StartRange, EndRange)
        MsgBox intmonths


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Seems correct to me. How many months would you expect using the same date?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    I realized its correct ! HAHAH ops.

    Then how to count
    1/11/2015 to 1/11/2015 as 1 month ?
    or June 2015 to Nov 2015 as 6 months ?
    Can I still use datediff?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    How does the commented-out line that adds one do?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    actually I don't know . I just anyhow add one

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DateDiff
    By TheHarleygirl2005 in forum Access
    Replies: 2
    Last Post: 07-09-2015, 11:44 AM
  2. DateDiff
    By mphynson44 in forum Queries
    Replies: 3
    Last Post: 02-27-2014, 07:28 PM
  3. Replies: 9
    Last Post: 09-23-2012, 07:55 AM
  4. How to use DateDiff?
    By teirrah1995 in forum Queries
    Replies: 10
    Last Post: 10-19-2010, 12:07 PM
  5. Need Help with Datediff
    By gonzod in forum Access
    Replies: 5
    Last Post: 08-26-2010, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums