Results 1 to 4 of 4
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Reading Date from SQL for query criteria

    Hey pplz,


    So I have an access frontend that I have made, worked 100% and all was well...

    THEN... the company moved to sql.

    I have reattached to the sql backend and everything is great EXCEPT the dates in sql are stored as text for some reason.


    "2010-11-06 00:00:00"

    BUT it is a text format....

    so my criteria has <Date() and it returns EVERYTHING :s

    Ideas?

    Changing the real table format to date isn't really an option as it is a "proper" program and I don't want to go around screwing with stuff like that randomly.

    Regards,

    Glenn

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try using CDate() in a query to convert to date value and apply filter to that constructed field.
    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.

  3. #3
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    yeh issue is that it is an aggregate and there are nulls.

    Currently Using
    DateDispensed (the sql version) in one column
    MyDate: Cdate(datedispensed)



    then doing a query that looks at that query (subquery?) which uses the newly constructed Cdates.

    If I aggregate the initial query it has errors

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Maybe provide an alternate value when null that would not be captured by the filter:

    CDate(Nz([fieldname], "12/31/2199"))

    Might use Is Null in query instead of Nz. Review http://allenbrowne.com/QueryPerfIssue.html
    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. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  2. Replies: 20
    Last Post: 01-13-2015, 02:23 PM
  3. Reading fields in querydef - how to find criteria
    By aytee111 in forum Programming
    Replies: 4
    Last Post: 05-08-2014, 03:44 PM
  4. Replies: 3
    Last Post: 08-21-2012, 03:05 PM
  5. Query Date Criteria
    By svanicek in forum Access
    Replies: 1
    Last Post: 07-09-2010, 11:13 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