Results 1 to 4 of 4
  1. #1
    JoshD is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    8

    Setting up a calculated field for dates

    Hi there,



    I have a simple need I think.....

    I need to set up a query that takes the difference between 2 dates and returns the difference as number. My table, let's call it (Data) has 8 fields, 2 of which are date fields (Date1, Date2). I want the query to show all 8 fields, plus a calculated field that shows the number of days between Date1 and Date2

    I tried this below, to no avail. (I know this is probably way off)

    SELECT Field1, Field2, Field3, Field4, Field5, Field6, Date1, Date2
    FROM Data
    BETWEEN Date1 AND Date2 AS DaysBetween

    Any help is appreciated. Thanks

  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
    You wouldn't want that Between statement there; that would be for a criteria. Try the DateDiff() function in your SELECT clause:

    SELECT Field1, Field2, Field3, Field4, Field5, Field6, Date1, Date2, DateDiff(...) AS DaysBetween
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JoshD is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    8
    Hmmm Ok, I tried this still no luck. Am I getting closer?

    SELECT*FROM Data
    =DateDiff("d",[Date1],[Date2]) AS DaysBetween

    Thanks again

  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
    I showed you the query syntax.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. How To Print Calculated Dates on Report
    By ChrisCione in forum Reports
    Replies: 2
    Last Post: 01-15-2011, 03:26 PM
  2. calculated field from calculated field?
    By RedGoneWILD in forum Reports
    Replies: 5
    Last Post: 08-03-2010, 02:32 PM
  3. Calculated field
    By nashr1928 in forum Forms
    Replies: 9
    Last Post: 08-01-2010, 01:59 PM
  4. Calculated field
    By nashr1928 in forum Forms
    Replies: 3
    Last Post: 07-22-2010, 05:10 AM
  5. Setting criteria in a calculated date field
    By SteveReberger in forum Access
    Replies: 0
    Last Post: 10-29-2008, 06:58 AM

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