lundi 7 septembre 2015

How can I write SQLite query C#?

On the start I would like write, that I use SQLite database. I have that table:

Raty - Installments ( 
    ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE,
    RataPrognDataSplaty  DATE, - the projected date of repayment
    RataDataWplaty       DATE, - date of payment
    RataMonit            DATE, - that and below are reminder dates, when it's write up
    RataWezw1            DATE, - 
    RataWezw2            DATE, - 
    RataWezwOstat        DATE, - 
    RataWezwDoWydania    DATE, - 
    RataWezwDoPracodawcy DATE  - 
);

I write programm to loans, if some clients doesn't pay, I set up issue a reminder to pay.

For example, I have list of 20 clients on a day, which doesn't pay for today with different late ( IN ('7', '14', '28', '42') ). They display in a table. I get the first one, I write reminder depending on the how many days he don\esn't pay, for example 7 days. And in for example in column RataMonit I write today date. And it's the main problem, I want that this client disappeared from list 20 clients, until he pay or next reminder - 14 days.

I wrote that query, but it doesn't works.

SELECT *
FROM Raty
WHERE RataDataWplaty IS NULL AND 
CAST(CAST((strftime('%s', 'now') - strftime('%s', RataPrognDataSplaty)) AS REAL)/60/60/24 AS INT) IN ('7', '14', '28', '42')
 AND ( 
(RataWezwDoPracodawcy IS NULL OR RataWezwDoPracodawcy == DATE('now')) OR 
(RataWezwDoWydania IS NULL OR RataWezwDoWydania == DATE('now')) OR 
(RataWezwOstat IS NULL OR RataWezwOstat == DATE('now')) OR 
(RataWezw2 IS NULL OR RataWezw2 == DATE('now')) OR 
(RataWezw1 IS NULL OR RataWezw1 == DATE('now')) OR 
(RataMonit IS NULL OR RataMonit == DATE('now')) );

Aucun commentaire:

Enregistrer un commentaire