Results 1 to 5 of 5

Thread: Date Difference

  1. #1
    Join Date
    Aug 2010
    Location
    California
    Posts
    8

    Unanswered: Date Difference

    I am attempting to create a simple query that counts the number of days between a start and ending date. I have a field for entering start date and one for entering ending date. When ever I use the DateDiff function and run the query I get a message the expression is typed wrong or is too complex. I am using Access 2007.

    Gene

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    What is the expression you have written?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Aug 2010
    Location
    California
    Posts
    8

    Date Difference

    The Expression is DateDiff [CurentDate] , [PreviousDate]

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    According to the Access help system (F1 key), the syntax of the DateDiff function is:
    Code:
    DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
    In the Query builder it becomes (for a difference in days):
    Code:
    x: DateDiff("d";[CurentDate];[PreviousDate])
    And in SQL:
    Code:
    DateDiff("d",[CurentDate];[PreviousDate]) AS x
    Have a nice day!

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    In the US the separator must be a comma rather than a semi-colon:

    DateDiff("d",[CurentDate], [PreviousDate])

    The semi-colon used in this manner will pop and error.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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