Results 1 to 7 of 7
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    convert sql to access queries

    All, I have an archive query that I got to work successfully in SQL 2008. When I converted it to us in Access 2003 query pass thru; its doesn't work.



    Code:
    SELECT dbo_tblSPInvoice.txtINVOICENUM, dbo.tblSPInvoice.txtCARRIERID, dbo_tblSPInvoice.txtCARRIERNAME, dbo_tblSPInvoice.txtCARRIERACCTNUM, dbo_tblSPInvoice.dteDATAENTDTE
    dbo_tblSPInvoice.dteINVOICEDTE, dbo_tblSPInvoice.dteMONTHPAID
    FROM dbo_tblSPInvoice
    WHERE DATEDIFF("d", [dteMONTHPAID],getdate ())>90;
    I changed the . to _. It seems to be failing at "where"
    Can someone point out whats the problem please.
    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,640
    If that's being run in an Access query (not a pass through), getdate would need to be Date (or Now if you want the time component).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Thank you for replying. I may want to change this to a pass thru in the future so I would want both ways. I'd appreciate your input.

  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,640
    No problem. Just use the function appropriate to the engine; Getdate() in SQL Server, Now() or Date() in Access.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Will do. Thanks so much.

  6. #6
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Ok I tried:
    Code:
    Date()>"90"
    in the date field query design; but it did not return the expected records. I m thinking it's because the table is a sql backend and the date is formatted as yyyy-mm-dd and access doesn't recognize because it thinks its a string???? And why is the "" around 90?
    I don't know. Anybody?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    If Access added the quotes, it's seeing the field as text, not a date. If that's all you have, it wouldn't be a valid comparison anyway. Your original SQL looked correct, so you might convert this to SQL view and see what it's producing.
    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. Convert QUERIES from ORACLE to ACCESS!?!
    By jas0214 in forum Queries
    Replies: 2
    Last Post: 04-23-2012, 07:22 AM
  2. Convert Excel to Access
    By wkenddad in forum Database Design
    Replies: 1
    Last Post: 04-19-2012, 01:55 AM
  3. Replies: 1
    Last Post: 11-25-2011, 11:16 AM
  4. Replies: 9
    Last Post: 08-07-2011, 11:21 AM
  5. Convert access 2003 to access 2010
    By Vera in forum Access
    Replies: 3
    Last Post: 07-16-2010, 11:01 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