jeudi 17 septembre 2015

SQLite Get Weekday Date from Field

I am trying to get the equivalent of this query in SQL in SQLite

SELECT DATE_ADD(now(),INTERVAL (DAYOFWEEK(S.start_date)+1) DAY) AS pymtdate FROM subscriptions

The purpose of this is that I have a start date and a weekly payment. I want to calculate the weekly payments for the next N days (in the example above this is for one week) for a number of start dates. In SQLite the nearest I can get to is

SELECT date('now', 'weekday stftime('%w', S.start_date)') AS pymtdate FROM subscriptions

but this isn't working as it blows out when I try to combine the weekday with a calculated value.

Any suggestions?

Aucun commentaire:

Enregistrer un commentaire