Access - Need Help Calculating in a Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bassstuf
    New Member
    • Oct 2008
    • 1

    Access - Need Help Calculating in a Table

    Ive Created a Access Data Base, and on my main table I have a field titled "Date Entered", which has the lists the date the record was created (through date() formula). What I want to do is have another field in that table that caculates the difference in days from the "date entered" column to the current date. I was using the formula:

    datediff("dd", [date entered], date())

    I am receiving the the error of "does not recognize the field "date entered", I think I have all the same format for the dates, but am really stumped by this one, so if anybody can give any suggestions to get this caculation, please let me know, this is my first database.
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    When you say 'table', is that what you really mean? You cannot place such a calculated field in the underlying table. It has to be placed in a query based on that table. The form of the SQL is similar to:

    Code:
    SELECT <other fields>, datediff("dd", [date entered], Date()) as DaysDiff
    FROM yourtable;
    If this is indeed what you are doing then you must check that the field's name is indeed 'Date Entered'. If it is, then to rule out any further problem with the DateDiff function itself you can simply subtract the dates directly to obtain the difference in days:

    Code:
    SELECT <other fields>, Date() - [date entered] as DaysDiff
    FROM yourtable;
    -Stewart

    Comment

    Working...