Results 1 to 2 of 2
  1. #1
    treder is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    1

    Question Sql Query

    Can anybody help me with this query? Obviousely a lot of tables on my end. The query runs fine until I get to the date section. I'm trying to tell my database to pull everybody in this catagory that has a tranaction date 30 days ago. I want to run a stored precedure every night so I need it to calculate the formula.


    Any ideas? I have been able to pull this in access but when I copy the sql code it doesn't work. Thanks!

    SELECT
    Name.ID, Trans.TRANSACTION_TYPE, Trans.TRANSACTION_DATE, Trans.GL_ACCOUNT,Coaching_Demo
    Primary_Coaching

    FROM Trans INNERJOIN Name ON Trans.BT_ID = Name.ID INNERJOIN Coaching_Demo ON Name.ID = Coaching_Demo.ID

    WHERE Trans.TRANSACTION_TYPE='DIST'AND Trans.GL_ACCOUNT='ME-101'AND Coaching_Demo.Primary_Coaching='Youth'



    AND Trans.TRANSACTION_DATE =GETDATE()-30

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Try

    Trans.Transaction_Date = date()-30

    Just note, this is looking for a SINGLE day, if you're trying to find everything that came appeared in the last 30 days you'd want something more like

    Trans.Transaction_Date >= date()-30

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

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