lundi 1 juin 2015

Database - Retrieving weekly recurring events

Currently I have 2 database tables:

**Tran**
id
recur_id
tran_date

**Recur**
id
start_date
end_date

I am currently only storing monthly repeating events and retrieving all transactions that occur on a monthly basis using:

SELECT t.id, t.recur_id, t.tran_date, coalesce (r.start_date, ''), coalesce (r.end_date, '') FROM tran t LEFT OUTER JOIN recur r ON t.recur_id = r.id WHERE strftime('%Y%m', tran_date) = strftime('%Y%m', ?)

I am trying now to extend my app to store weekly recurring transactions, I will add a new column to the Recur table to store the interval (weekly/monthly). Can anyone help on how I could retrieve all weekly recurring transactions for a particular month using a SQL query?

Aucun commentaire:

Enregistrer un commentaire