-
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
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules