Advanced search Query library
Is there a library of helpful advance searches - or advanced query commands available?
I have a query that was built by someone else, that pulls out all potential payments for this current month - however, I actually want to adjust this to pull through next months too - so I can run a report on payments due next month that are still contigent
It would be really helpful if we had somewhere in the resources sections of common query commands and what they actually do - to help us build these queries ourselves (As the ‘insert expression’ when building doesnt cover everything)
My query is:
(month(CAST(Payments.Schedule_Date AS DATE)) = month(getdate()) AND year(CAST(Payments.Schedule_Date AS DATE)) = year(getdate()) AND Payments.Payment_Date IS NULL) Payments.Schedule_Date IS NULL
Comments
-
@Louisa Robinson I’ve pinged a few people internally here that might be able to help. Will follow up.
1 -
@Louisa Robinson Hi Louisa. This is a great idea, and we would be happy to contribute to building an advanced query library and demonstrating some techniques.
It appears there is an error in the query text you have posted - that is not a valid query as it stands.Here is one approach to solving your problem.
((MONTH(CAST(Payments.Schedule_Date AS DATE)) = MONTH(GETDATE()) AND YEAR(CAST(Payments.Schedule_Date AS DATE)) = YEAR(GETDATE())) OR (MONTH(CAST(Payments.Schedule_Date AS DATE)) = (MONTH(GETDATE()) + 1) AND (MONTH(GETDATE()) < 12) AND YEAR(CAST(Payments.Schedule_Date AS DATE)) = YEAR(GETDATE())) OR ((MONTH(CAST(Payments.Schedule_Date AS DATE)) = 1 AND (MONTH(GETDATE()) = 12) AND YEAR(CAST(Payments.Schedule_Date AS DATE)) = (YEAR(GETDATE()) + 1)))) AND Payments.Payment_Date IS NULL AND NOT Payments.Schedule_Date IS NULL
To get the next month, we can simply add one to MONTH(GETDATE()), but we run into problems when the current date is in December, and so the next month is 1 (not 13), and the year is going to be next year, ie, YEAR(GETDATE()) + 1. The above query should work throughout the year.
To break it down:
Scheduled Date is the current month:
(MONTH(CAST(Payments.Schedule_Date AS DATE)) = MONTH(GETDATE()) AND YEAR(CAST(Payments.Schedule_Date AS DATE)) = YEAR(GETDATE()))
Scheduled Date is the next month and MONTH(GETDATE()) < 12:
(MONTH(CAST(Payments.Schedule_Date AS DATE)) = (MONTH(GETDATE()) + 1) AND (MONTH(GETDATE()) < 12) AND YEAR(CAST(Payments.Schedule_Date AS DATE)) = YEAR(GETDATE()))
Scheduled Date is the next month and MONTH(GETDATE()) = 12:
(MONTH(CAST(Payments.Schedule_Date AS DATE)) = 1 AND (MONTH(GETDATE()) = 12) AND YEAR(CAST(Payments.Schedule_Date AS DATE)) = (YEAR(GETDATE()) + 1))
Cheers
Justin
2 -
@Justin Finighan This is super helpful! I realised I stuck in an extra (wrong) part of the code on the end, i was trying to remove a part that had a staff name in.
it should have been (month(CAST(Payments.Schedule_Date AS DATE)) = month(getdate()) AND year(CAST(Payments.Schedule_Date AS DATE)) = year(getdate()) AND Payments.Payment_Date IS NULL)
0 -
@Ray Borkman thank you - i realised i typed the coding wrong! (Copy and paste issue by user!)
it should have read (month(CAST(Payments.Schedule_Date AS DATE)) = month(getdate()) AND year(CAST(Payments.Schedule_Date AS DATE)) = year(getdate()) AND Payments.Payment_Date IS NULL)
0
Categories
- All Categories
- 6 Blackbaud Community Help
- 209 bbcon®
- 1.4K Blackbaud Altru®
- 395 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 360 Blackbaud eTapestry®
- 2.5K Blackbaud Financial Edge NXT®
- 648 Blackbaud Grantmaking™
- 566 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 937 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.5K Blackbaud Raiser's Edge NXT®
- 3.7K SKY Developer
- 247 ResearchPoint™
- 118 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 239 The Tap (Just for Fun)
- 33 Blackbaud Community Challenges
- 31 PowerUp Challenges
- 3 (Open) PowerUp Challenge: Data Health
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 782 Community News
- 2.9K Jobs Board
- 53 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)


