Results 1 to 7 of 7
  1. #1
    xeon_tsd is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3

    datediff in query

    I am trying to get a datediff in a query between two fields.



    Code:
    DateDiff("d"[MasterServerList].[ScheduleDate],[MasterServerList].[SEReceivedDate])
    I have also tried

    Code:
     DateDiff("d"[MasterServerList]![ScheduleDate],[MasterServerList]![SEReceivedDate])
    The rest of the query looks like this and is fine.

    Code:
    SELECT MasterServerList.ServerName, MasterServerList.C_ApplicationID, MasterServerList.Action, MasterServerList.EOL_ActionStatus, MasterServerList.ScheduleDate, MasterServerList.SEReceivedDate, MasterServerList.SEDesignDate
    FROM MasterServerList
    WHERE (((MasterServerList.Action) Like "Refresh") AND ((MasterServerList.EOL_ActionStatus) Like "Scheduled") AND ((MasterServerList.ScheduleDate)<=#4/30/2014#));
    Note that I am calling these same two parameters in the beginning of the query. I want to display the dates and the datediff.

    grr =/

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    see this link

  3. #3
    xeon_tsd is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3
    That says to use the above, only with single ticks instead of quotes, which i have also tried to no avail... I have even tried to run this as a new query from the original one. still grrr =/

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by xeon_tsd View Post
    ...only with single ticks instead of quotes....
    That should do it.
    'd'

    The other thing is to consider the field that the date is in. Does the query know it is a date field? Is the field in the table data type Date?

  5. #5
    xeon_tsd is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3
    yup the field is a date field.
    this is access 2010 if that matters.

    meh what am I not seeing?

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would expect the following to work by placing it in a new field as an alias

    MyAlias: DateDiff('d'[MasterServerList].[ScheduleDate],[MasterServerList].[SEReceivedDate])

    and the resulting SQL should read something like

    MasterServerList.SEDesignDate, DateDiff('d'[MasterServerList].[ScheduleDate],[MasterServerList].[SEReceivedDate]) AS MyAlias FROM MasterServerList

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Missing a comma:

    DateDiff("d",[MasterServerList]![ScheduleDate],[MasterServerList]![SEReceivedDate])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. DateDiff in a query
    By Jim.H. in forum Access
    Replies: 4
    Last Post: 01-22-2012, 01:45 PM
  2. Query datediff error
    By RayMilhon in forum Queries
    Replies: 3
    Last Post: 10-05-2011, 12:13 PM
  3. DateDiff Missing Operator? Long Query
    By ewassmer in forum Queries
    Replies: 1
    Last Post: 08-25-2011, 10:46 AM
  4. Need Help with Datediff
    By gonzod in forum Access
    Replies: 5
    Last Post: 08-26-2010, 02:29 PM
  5. Query DateDiff calculation excluding weekends
    By Masterfinn in forum Queries
    Replies: 3
    Last Post: 04-01-2010, 09:46 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