Hi,

I have a small database:
DatesOfYear.db

with only one table:

CREATE TABLE Dates(id integer PRIMARY KEY UNIQUE, TheDate date NOT NULL);

I insert into the table some datas with:

INSERT INTO Dates VALUES(1,'2018-04-01');
INSERT INTO Dates VALUES(2,'2018-04-02');
INSERT INTO Dates VALUES(3,'2018-04-03');
INSERT INTO Dates VALUES(4,'2018-04-04');
INSERT INTO Dates VALUES(5,'2018-04-05');
INSERT INTO Dates VALUES(6,'2018-04-06');
INSERT INTO Dates VALUES(7,'2018-04-07');
INSERT INTO Dates VALUES(8,'2018-04-08');
INSERT INTO Dates VALUES(9,'2018-04-09');
INSERT INTO Dates VALUES(10,'2018-04-10');
INSERT INTO Dates VALUES(11,'2018-04-11');
INSERT INTO Dates VALUES(12,'2018-04-12');
INSERT INTO Dates VALUES(13,'2018-04-13');
INSERT INTO Dates VALUES(14,'2018-04-14');
INSERT INTO Dates VALUES(15,'2018-04-15');

I want the following by using SELECT and CASE:

to select the date:
 if TheDate is = with the current date then select that TheDate
 else to select only once the next date  from Dates table.

I tried with this query:
SELECT CASE TheDate = date('now') WHEN TheDate THEN TheDate ELSE
date('now','+1 day') END TheDate FROM Dates;

and the output is this:
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13
2018-04-13

but I expect - because to day is 2018-04-12 this:
2018-04-12

What am I doing wrong?
NOTE! The dates are in Hungarian.

-- 
Best, Pali
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to