Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

One can't proceed from the informal to the formal by formal means.


devel / comp.lang.tcl / Re: sqlite records between dates

SubjectAuthor
* sqlite records between datesShaun Kulesa
+* Re: sqlite records between datested@loft.tnolan.com (Ted Nolan
|`- Re: sqlite records between datesShaun Kulesa
+* Re: sqlite records between datesRich
|`* Re: sqlite records between datesShaun Kulesa
| `* Re: sqlite records between datessaitology9
|  `* Re: sqlite records between datesRich
|   `- Re: sqlite records between datesShaun Kulesa
`- Re: sqlite records between datesRichard Damon

1
sqlite records between dates

<145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21670&group=comp.lang.tcl#21670

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:4722:b0:746:9174:3d3c with SMTP id bs34-20020a05620a472200b0074691743d3cmr2431863qkb.13.1680796858922;
Thu, 06 Apr 2023 09:00:58 -0700 (PDT)
X-Received: by 2002:a05:620a:2482:b0:742:f3f8:77ae with SMTP id
i2-20020a05620a248200b00742f3f877aemr2773309qkn.6.1680796858677; Thu, 06 Apr
2023 09:00:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 6 Apr 2023 09:00:58 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>
Subject: sqlite records between dates
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Thu, 06 Apr 2023 16:00:58 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1492
 by: Shaun Kulesa - Thu, 6 Apr 2023 16:00 UTC

Hello,

I am trying to get records between two dates, the date field is the TEXT data type.

I got this working for dates in the same month, this will return values for each day:
"SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN '27/03/2023' AND '31/03/2023'"

This does not work for separate months though, if I do it will return nothing:
"SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN '27/03/2023' AND '01/04/2023'"

Should I be doing this another way?

Thanks.

Re: sqlite records between dates

<k989seF29ekU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21671&group=comp.lang.tcl#21671

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: @ednolan (ted@loft.tnolan.com (Ted Nolan)
Newsgroups: comp.lang.tcl
Subject: Re: sqlite records between dates
Date: 6 Apr 2023 16:21:34 GMT
Organization: loft
Lines: 29
Message-ID: <k989seF29ekU1@mid.individual.net>
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>
X-Trace: individual.net j+v2+16ByancFbbb77U2hAVOgHNE87HP8iSabjZOFNyL2lJxZW
X-Orig-Path: not-for-mail
Cancel-Lock: sha1:g5CisRpMtd+NDFg/48I5ccx39BQ=
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
 by: ted@loft.tnolan.com - Thu, 6 Apr 2023 16:21 UTC

In article <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>,
Shaun Kulesa <shaunkulesa@gmail.com> wrote:
>Hello,
>
>I am trying to get records between two dates, the date field is the TEXT
>data type.
>
>I got this working for dates in the same month, this will return values
>for each day:
>"SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN
>'27/03/2023' AND '31/03/2023'"
>
>This does not work for separate months though, if I do it will return nothing:
>"SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN
>'27/03/2023' AND '01/04/2023'"
>
>Should I be doing this another way?
>
>Thanks.

Maybe something with unixepoch()?

SELECT * FROM customer_orders WHERE stock_id=? AND
date > unixepoch('27/03/2023') AND date < unixepoch('31/03/2023')

(I don't have sqllite, so I have not actually tried that).
--
columbiaclosings.com
What's not in Columbia anymore..

Re: sqlite records between dates

<61562c2a-43d4-464a-bca1-ef1e3e60e418n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21672&group=comp.lang.tcl#21672

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:298e:b0:746:76f1:5d37 with SMTP id r14-20020a05620a298e00b0074676f15d37mr2466166qkp.7.1680798726208;
Thu, 06 Apr 2023 09:32:06 -0700 (PDT)
X-Received: by 2002:a05:620a:424f:b0:745:6cc5:e54f with SMTP id
w15-20020a05620a424f00b007456cc5e54fmr2270542qko.15.1680798726024; Thu, 06
Apr 2023 09:32:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 6 Apr 2023 09:32:05 -0700 (PDT)
In-Reply-To: <k989seF29ekU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com> <k989seF29ekU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <61562c2a-43d4-464a-bca1-ef1e3e60e418n@googlegroups.com>
Subject: Re: sqlite records between dates
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Thu, 06 Apr 2023 16:32:06 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1176
 by: Shaun Kulesa - Thu, 6 Apr 2023 16:32 UTC

Sorry, I couldn't get that to work.

Re: sqlite records between dates

<u0mto1$e201$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21673&group=comp.lang.tcl#21673

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: sqlite records between dates
Date: Thu, 6 Apr 2023 16:58:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <u0mto1$e201$1@dont-email.me>
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>
Injection-Date: Thu, 6 Apr 2023 16:58:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3578e613540f2be6e0bbd09a88e46ac3";
logging-data="460801"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DVbPMSv3Sj9d6jNm5VgKJ"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:QmCna++74gkjo9UwCU7DOqFEacw=
 by: Rich - Thu, 6 Apr 2023 16:58 UTC

Shaun Kulesa <shaunkulesa@gmail.com> wrote:
> Hello,
>
> I am trying to get records between two dates, the date field is the
> TEXT data type.
>
> I got this working for dates in the same month, this will return
> values for each day: "SELECT * FROM customer_orders WHERE stock_id=?
> AND date BETWEEN '27/03/2023' AND '31/03/2023'"
>
> This does not work for separate months though, if I do it will return
> nothing: "SELECT * FROM customer_orders WHERE stock_id=? AND date
> BETWEEN '27/03/2023' AND '01/04/2023'"
>
> Should I be doing this another way?

Do you have freedom to 'redo' the database table?

If yes, then change the date column to be one of two items:

1) If you want to stick with 'text' colums, use an ISO8601 style date:
YYYY MM DD (i.e. YYYY-MM-DD or YYYY/MM/DD). This format has the
advantage that the ASCII text sort order of the strings is *also* a
sort in date order. This will let your 'between' query actually find
dates that are 'between' those values

2) Switch the dates to be unix epoch integer values, then a normal
integer range will find 'between' values.

And, note that for 'display' purposes, you can display whatever format
a user wants externally, independent of the format you use inside the
DB.

Re: sqlite records between dates

<a4d60495-44f2-4314-831e-6c0bf0f09d9fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21674&group=comp.lang.tcl#21674

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:18a8:b0:3e0:dee4:c925 with SMTP id v40-20020a05622a18a800b003e0dee4c925mr2750765qtc.5.1680802002457;
Thu, 06 Apr 2023 10:26:42 -0700 (PDT)
X-Received: by 2002:a05:620a:191c:b0:748:4a62:2ba3 with SMTP id
bj28-20020a05620a191c00b007484a622ba3mr2505522qkb.8.1680802002133; Thu, 06
Apr 2023 10:26:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 6 Apr 2023 10:26:41 -0700 (PDT)
In-Reply-To: <u0mto1$e201$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com> <u0mto1$e201$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a4d60495-44f2-4314-831e-6c0bf0f09d9fn@googlegroups.com>
Subject: Re: sqlite records between dates
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Thu, 06 Apr 2023 17:26:42 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1743
 by: Shaun Kulesa - Thu, 6 Apr 2023 17:26 UTC

I totally agree with your last statement about displaying it in whatever format on the GUI side.

I stuck with the TEXT and changed the dates in the database to be YYYY/MM/DD, I must of missed something because if I do the query with BETWEEN '2023/03/27' AND '2023/03/31' (or '2023/04/01') it will return nothing.

SELECT * FROM customer_orders WHERE date BETWEEN '2023/03/27' AND '2023/03/31'

I'm going to attach the database and a image of the contents so you can have a reference:
https://drive.google.com/drive/folders/16sMDU4_DDbCbaaEJRqhQMQQvgvxnZ6xk?usp=sharing

Thank you for your help so far.

Re: sqlite records between dates

<LRDXL.1907820$iS99.1281209@fx16.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21675&group=comp.lang.tcl#21675

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.9.1
Subject: Re: sqlite records between dates
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 22
Message-ID: <LRDXL.1907820$iS99.1281209@fx16.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Thu, 6 Apr 2023 14:05:31 -0400
X-Received-Bytes: 1763
 by: Richard Damon - Thu, 6 Apr 2023 18:05 UTC

On 4/6/23 12:00 PM, Shaun Kulesa wrote:
> Hello,
>
> I am trying to get records between two dates, the date field is the TEXT data type.
>
> I got this working for dates in the same month, this will return values for each day:
> "SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN '27/03/2023' AND '31/03/2023'"
>
> This does not work for separate months though, if I do it will return nothing:
> "SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN '27/03/2023' AND '01/04/2023'"
>
> Should I be doing this another way?
>
> Thanks.

Since the field is TEXT, the BETWEEN operation will work on the data as
TEXT, not trying to interprete it as a date.

You either need to process the date field by using a function to convert
the date to something that actually works as a date, or store the dates
in a format that work correctly, like YYYY-MM-DD

Re: sqlite records between dates

<u0n2ma$essj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21676&group=comp.lang.tcl#21676

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: sqlite records between dates
Date: Thu, 6 Apr 2023 14:23:04 -0400
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <u0n2ma$essj$1@dont-email.me>
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>
<u0mto1$e201$1@dont-email.me>
<a4d60495-44f2-4314-831e-6c0bf0f09d9fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 6 Apr 2023 18:23:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f2ea3196f9de5b48563b42de97d60cae";
logging-data="488339"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oWi1RKb9xfJUae4QsnoE/"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:4IkJX3hX8x/+zwzon50Q2FSdYfc=
Content-Language: en-US
In-Reply-To: <a4d60495-44f2-4314-831e-6c0bf0f09d9fn@googlegroups.com>
 by: saitology9 - Thu, 6 Apr 2023 18:23 UTC

On 4/6/2023 1:26 PM, Shaun Kulesa wrote:
> This does not work for separate months though, if I do it will return nothing:
> "SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN '27/03/2023' AND '01/04/2023'"

This is because you are comparing strings "27/..." and "01/..."

> I stuck with the TEXT and changed the dates in the database to be YYYY/MM/DD, I must of missed something because if I do the query with BETWEEN '2023/03/27' AND '2023/03/31' (or '2023/04/01') it will return nothing.
>
> SELECT * FROM customer_orders WHERE date BETWEEN '2023/03/27' AND '2023/03/31'
>

You can use date formatting functions and then do your sql or you could
stick to a format that should work implicitly - like this which is safe
for both string and date comparisons: 'YYYY-MM-DD' will work in iether case.

Re: sqlite records between dates

<u0n5j2$fb23$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21677&group=comp.lang.tcl#21677

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: sqlite records between dates
Date: Thu, 6 Apr 2023 19:12:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u0n5j2$fb23$1@dont-email.me>
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com> <u0mto1$e201$1@dont-email.me> <a4d60495-44f2-4314-831e-6c0bf0f09d9fn@googlegroups.com> <u0n2ma$essj$1@dont-email.me>
Injection-Date: Thu, 6 Apr 2023 19:12:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3578e613540f2be6e0bbd09a88e46ac3";
logging-data="502851"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180NxThadD0j7JScrNiIc3c"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:JtYohNowTElWq3lwPyxoq8d3dd4=
 by: Rich - Thu, 6 Apr 2023 19:12 UTC

saitology9 <saitology9@gmail.com> wrote:
> On 4/6/2023 1:26 PM, Shaun Kulesa wrote:
>> This does not work for separate months though, if I do it will return nothing:
>> "SELECT * FROM customer_orders WHERE stock_id=? AND date BETWEEN '27/03/2023' AND '01/04/2023'"
>
> This is because you are comparing strings "27/..." and "01/..."

And also because your db now contains YYYY-MM-DD and you are using / in
your between.

From your DB:

sqlite> select * from customer_orders ;
id stock_id order_cost quantity shipped date
-- -------- ---------- -------- ------- ----------
18 2 11.9 7 0 2023-04-01
19 2 17 10 0 2023-03-27
20 2 25.5 15 0 2023-03-28
sqlite> select * from customer_orders where date between '2023-03-27' and '2023-04-01';
id stock_id order_cost quantity shipped date
-- -------- ---------- -------- ------- ----------
18 2 11.9 7 0 2023-04-01
19 2 17 10 0 2023-03-27
20 2 25.5 15 0 2023-03-28

If you format the dates in the query the same way as the DB now stores
them, and put the smaller date first in the 'between' query, it works.

Re: sqlite records between dates

<9be8c28b-6255-4757-9376-d48cf39799e9n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21678&group=comp.lang.tcl#21678

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:4153:b0:74a:5990:33bc with SMTP id k19-20020a05620a415300b0074a599033bcmr2319901qko.11.1680812390686;
Thu, 06 Apr 2023 13:19:50 -0700 (PDT)
X-Received: by 2002:ac8:7d16:0:b0:3d2:8d87:6710 with SMTP id
g22-20020ac87d16000000b003d28d876710mr16248qtb.12.1680812390429; Thu, 06 Apr
2023 13:19:50 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Thu, 6 Apr 2023 13:19:50 -0700 (PDT)
In-Reply-To: <u0n5j2$fb23$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=87.115.149.231; posting-account=Be2r4goAAACg4Ko_BkJ0V-RlkGAdXGng
NNTP-Posting-Host: 87.115.149.231
References: <145ca78b-35de-4641-b895-3c1eeb571139n@googlegroups.com>
<u0mto1$e201$1@dont-email.me> <a4d60495-44f2-4314-831e-6c0bf0f09d9fn@googlegroups.com>
<u0n2ma$essj$1@dont-email.me> <u0n5j2$fb23$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9be8c28b-6255-4757-9376-d48cf39799e9n@googlegroups.com>
Subject: Re: sqlite records between dates
From: shaunkulesa@gmail.com (Shaun Kulesa)
Injection-Date: Thu, 06 Apr 2023 20:19:50 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1356
 by: Shaun Kulesa - Thu, 6 Apr 2023 20:19 UTC

Yes I see, I forgot to switch to using the dash.

It's been a long day, thank you everyone for your help.


devel / comp.lang.tcl / Re: sqlite records between dates

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor