Is it possible through a plugin or the API to have a dynamic group based on a query?
For example I need to have a group that consists of all users in Group A who are not in Group B.
More advanced features that would be nice would include dates.
eg. All users who joined Group A in the last 12 months who are not in Group B.
I realize I can write queries to do this but we would like to somehow save it so our clients can call them up easily.
I think your ideas are covered in the Examples section in the documentation. It contains example code on how to check if a user belongs to a group and how to add the user to a group.
If though you have questions on these, please reply here to give you more info on that.