Re: [sqlite] Using CTE with date comparison

2018-08-08 Thread Csányi Pál
On Mon, Aug 06, 2018 at 05:02:00PM +, David Raymond wrote: > The whole fencepost thing is probably doing weird things. Here's my take on > it. > This is "time to get from A to B". If you want "Total timespan from A to B > inclusive" then just add 1 day. > > Trying to do the +1 day or -1 day

Re: [sqlite] Using CTE with date comparison

2018-08-06 Thread David Raymond
te.org] On Behalf Of Csányi Pál Sent: Monday, August 06, 2018 10:55 AM To: SQLite mailing list Subject: Re: [sqlite] Using CTE with date comparison On Sun, Aug 05, 2018 at 01:12:17PM -0600, Keith Medcalf wrote: > > >Some where in the WITH clause above I want to put '+1 day' in the > >

Re: [sqlite] Using CTE with date comparison

2018-08-06 Thread Csányi Pál
On Sun, Aug 05, 2018 at 01:12:17PM -0600, Keith Medcalf wrote: > > >Some where in the WITH clause above I want to put '+1 day' in the > >command out there. > > That is because the query does not count the StartDate but does count the > EndDate, so if your EndDate is the next day from the

Re: [sqlite] Using CTE with date comparison

2018-08-05 Thread Keith Medcalf
;From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of pali >Sent: Sunday, 5 August, 2018 07:35 >To: SQLite mailing list >Subject: Re: [sqlite] Using CTE with date comparison > >On Sun, Aug 05, 2018 at 05:25:02AM -0600, Keith Medcalf wrote: >&g

Re: [sqlite] Using CTE with date comparison

2018-08-05 Thread pali
On Sun, Aug 05, 2018 at 05:25:02AM -0600, Keith Medcalf wrote: > > :StartDate and :EndDate are NAMED PARAMETERS for when your application > executes the statement (that is, they are substituted with the values you > want for the StartDate and EndDate respectively. I understand now. Thank you!

Re: [sqlite] Using CTE with date comparison

2018-08-05 Thread Keith Medcalf
...@mailinglists.sqlite.org] On Behalf Of Csányi Pál >Sent: Sunday, 5 August, 2018 02:08 >To: SQLite mailing list >Subject: Re: [sqlite] Using CTE with date comparison > >2018-08-05 0:18 GMT+02:00 Keith Medcalf : >> >> WITH RECURSIVE >> dates(dateD) AS (VALUES(:Sta

Re: [sqlite] Using CTE with date comparison

2018-08-05 Thread Csányi Pál
2018-08-05 0:18 GMT+02:00 Keith Medcalf : > > WITH RECURSIVE > dates(dateD) AS (VALUES(:StartDate) > UNION ALL > SELECT date(dateD, '+1 year') > FROM dates >WHERE date(dateD, '+1 year') <= :EndDate > ) > SELECT

Re: [sqlite] Using CTE with date comparison

2018-08-04 Thread Keith Medcalf
QLite mailing list >Subject: Re: [sqlite] Using CTE with date comparison > >2018-08-04 14:07 GMT+02:00 Csányi Pál : >> 2018-08-03 13:09 GMT+02:00 R Smith : >> >>> Do you want a recursive query that will add all years between 3 >October and >>> some other date

Re: [sqlite] Using CTE with date comparison

2018-08-04 Thread Csányi Pál
2018-08-04 14:07 GMT+02:00 Csányi Pál : > 2018-08-03 13:09 GMT+02:00 R Smith : > >> Do you want a recursive query that will add all years between 3 October and >> some other date, but NOT the first year and NOT the last year? > > I want a recursive query that gives years to the start date until it

Re: [sqlite] Using CTE with date comparison

2018-08-04 Thread Csányi Pál
2018-08-03 13:09 GMT+02:00 R Smith : > Do you want a recursive query that will add all years between 3 October and > some other date, but NOT the first year and NOT the last year? I want a recursive query that gives years to the start date until it reaches the end date or if it exceeds the end

Re: [sqlite] Using CTE with date comparison

2018-08-03 Thread Kees Nuyt
On Fri, 3 Aug 2018 15:11:06 +0200, Csányi Pál wrote: >The database is so far with only one table: >CREATE TABLE MyLengthOfService ( >id INT PRIMARY KEY > UNIQUE, >WorkPlaceName TEXT, You shouldn't use UNIQUE for the PRIMARY KEY. Any PRIMARY KEY is

Re: [sqlite] Using CTE with date comparison

2018-08-03 Thread Csányi Pál
2018-08-03 13:09 GMT+02:00 R Smith : > > > On 2018/08/03 12:35 PM, Csányi Pál wrote: >> >> 2018-08-02 23:12 GMT+02:00 R Smith : >>> >>> On 2018/08/02 10:29 PM, Csányi Pál wrote: Hi, I just want to know why the following SQLite query does not work as I expected?

Re: [sqlite] Using CTE with date comparison

2018-08-03 Thread R Smith
On 2018/08/03 12:35 PM, Csányi Pál wrote: 2018-08-02 23:12 GMT+02:00 R Smith : On 2018/08/02 10:29 PM, Csányi Pál wrote: Hi, I just want to know why the following SQLite query does not work as I expected? WITH RECURSIVE dates(dateD) AS ( VALUES('2015-10-03') UNION ALL SELECT date(dateD,

Re: [sqlite] Using CTE with date comparison

2018-08-03 Thread Csányi Pál
2018-08-02 23:12 GMT+02:00 R Smith : > On 2018/08/02 10:29 PM, Csányi Pál wrote: >> >> Hi, >> >> I just want to know why the following SQLite query does not work as I >> expected? >> >> WITH RECURSIVE dates(dateD) AS ( VALUES('2015-10-03') UNION ALL SELECT >> date(dateD, '+1 year') FROM dates

Re: [sqlite] Using CTE with date comparison

2018-08-03 Thread Csányi Pál
2018-08-02 23:12 GMT+02:00 R Smith : > On 2018/08/02 10:29 PM, Csányi Pál wrote: >> >> Hi, >> >> I just want to know why the following SQLite query does not work as I >> expected? >> >> WITH RECURSIVE dates(dateD) AS ( VALUES('2015-10-03') UNION ALL SELECT >> date(dateD, '+1 year') FROM dates

Re: [sqlite] Using CTE with date comparison

2018-08-02 Thread R Smith
On 2018/08/02 10:29 PM, Csányi Pál wrote: Hi, I just want to know why the following SQLite query does not work as I expected? WITH RECURSIVE dates(dateD) AS ( VALUES('2015-10-03') UNION ALL SELECT date(dateD, '+1 year') FROM dates WHERE date(dateD) <= date('2016-11-01') ) SELECT max(dateD),

[sqlite] Using CTE with date comparison

2018-08-02 Thread Csányi Pál
Hi, I just want to know why the following SQLite query does not work as I expected? WITH RECURSIVE dates(dateD) AS ( VALUES('2015-10-03') UNION ALL SELECT date(dateD, '+1 year') FROM dates WHERE date(dateD) <= date('2016-11-01') ) SELECT max(dateD), count(dateD) FROM dates; 2017-10-03|3 which is