temporal queries

I’ve found a number of libraries for building temporal expressions up such as


Are there any libraries around for turning these into temporal queries on a database. For example given there
are a set of airline flight numbers each with it’s own unique schedule. I then wish to know something

"select all flight numbers that fly  on the first tuesday of each month except december"

Are there any libraries that can do such a thing?