Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Everything should be made as simple as possible, but not simpler. -- Albert Einstein


devel / comp.databases.ms-access / Re: Need some SQL

SubjectAuthor
* Need some SQLKeith Tizzard
+* Re: Need some SQLAmmammata
|`- Re: Need some SQLAmmammata
+* Re: Need some SQLRon Paii
|`* Re: Need some SQLRon Paii
| `* Re: Need some SQLKeith Tizzard
|  `* Re: Need some SQLRon Paii
|   `* Re: Need some SQLKeith Tizzard
|    `* Re: Need some SQLRon Paii
|     `* Re: Need some SQLKeith Tizzard
|      `- Re: Need some SQLNeil
+* Re: Need some SQLRon Weiner
|`* Re: Need some SQLKeith Tizzard
| `* Re: Need some SQLRon Weiner
|  `* Re: Need some SQLKeith Tizzard
|   +- Re: Need some SQLRon Weiner
|   `* Re: Need some SQLRon Weiner
|    `* Re: Need some SQLAmmammata
|     `* Re: Need some SQLKeith Tizzard
|      +- Re: Need some SQLmal....@gmail.com
|      `* Re: Need some SQLRon Weiner
|       +* Re: Need some SQLNeil
|       |`* Re: Need some SQLNeil
|       | +* Re: Need some SQLRon Weiner
|       | |`* Re: Need some SQLNeil
|       | | `* Re: Need some SQLRon Weiner
|       | |  `* Re: Need some SQLNeil
|       | |   `* Re: Need some SQLRon Weiner
|       | |    `- Re: Need some SQLNeil
|       | `* Re: Need some SQLKeith Tizzard
|       |  `* Re: Need some SQLNeil
|       |   `* Re: Need some SQLNeil
|       |    `* Re: Need some SQLKeith Tizzard
|       |     `* Re: Need some SQLNeil
|       |      `* Re: Need some SQLNeil
|       |       `- Re: Need some SQLNeil
|       `* Re: Need some SQLRon Weiner
|        +* Re: Need some SQLKeith Tizzard
|        |`- Re: Need some SQLAmmammata
|        `- Re: Need some SQLRon Weiner
`- Re: Need some SQLMike P

Pages:12
Re: Need some SQL

<sfbijg$tjn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=500&group=comp.databases.ms-access#500

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: rw...@domain.com (Ron Weiner)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Sun, 15 Aug 2021 13:23:58 -0400
Organization: WorksRite
Lines: 66
Message-ID: <sfbijg$tjn$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com> <sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com> <sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com> <sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1> <8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me> <sfbb72$9al$1@dont-email.me> <sfbdth$1kd$1@dont-email.me> <sfbhf1$7ei$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Aug 2021 17:24:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1b76ae08641c2632c06c7d414a24e61d";
logging-data="30327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JitrBv4GZzKzCfPm3IGp+"
Cancel-Lock: sha1:DTM7MiMUKudRmJjaP5/qTL9tZrg=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210815-2, 8/15/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Sun, 15 Aug 2021 17:23 UTC

Neil has brought this to us :
> On 8/15/2021 12:03 PM, Ron Weiner wrote:
>> It happens that Neil formulated :
>>> On 8/15/2021 10:54 AM, Neil wrote:
>>>> If I understand it, the year is not a factor, just the day and month. If
>>>> so, the search could be structured:
>>>>
>>>> WHERE Day >= 7 AND Month >= 11 AND Day <= 14 AND Month <= 1*
>>>>
>>>> *This allows for Month <= 3, etc.
>>>>
>>>> Neil
>>>>
>>> OOPS! Wrote this before finishing my coffee!
>>>
>>> The structure should be:
>>> WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1*
>>>
>>> -- best regards,
>>>
>>> Neil
>>
>> Sorry Neil, I am afraid you are going to need more coffee. The following
>> Sql (I believe) uses the Where Clause you suggested.
>>
>> SELECT RegDate, VIN
>> FROM tblVehicle
>> WHERE (((Month([regdate]))>=11) AND ((Day([regDate]))>=7))
>> OR (((Month([regdate]))<=1) AND ((Day([regDate]))<=14));
>>
>> Returns:
>>
>> RegDate        VIN
>> 11/8/2001    235
>> 12/12/2001    321
>> 12/21/2019    665
>> 1/12/2011    215
>>
>> The expected result is:
>>
>> RegDate        VIN
>> 11/8/2001    235
>> 12/3/2017    332
>> 12/12/2001    321
>> 12/21/2019    665
>> 1/12/2011    215
>>
>> Rdub
>
> Since #332, falling in March, doesn't fit the parameters why is that expected
> to be included in the inquiry?
>
> --
> best regards,
>
> Neil
I live in the land of Feet, Inches, Pounds and Ounces, and we do dates
here in the form of Month / Day / Year. So #332 is Dec 3rd (in my
world) which does fit into the parameters. Sorry for the confusion.

I guess this is just another example of why a significant percentage of
the people living in USA are totally F'n NUTS. I don’t even want to
get into COVID vaccination hesitancy, universal healthcare, or voting
rights. These days it's really getting hard to live here. Very sad!

Rdub

Re: Need some SQL

<sfbngu$off$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=501&group=comp.databases.ms-access#501

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: rw...@domain.com (Ron Weiner)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Sun, 15 Aug 2021 14:47:56 -0400
Organization: WorksRite
Lines: 35
Message-ID: <sfbngu$off$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com> <sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com> <sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com> <sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1> <8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Aug 2021 18:47:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1b76ae08641c2632c06c7d414a24e61d";
logging-data="25071"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9PHHyMPpQgm7NbL8DN8M9"
Cancel-Lock: sha1:p9SXJqrnm/JySt+de+bbmV+DTh8=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210815-2, 8/15/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Sun, 15 Aug 2021 18:47 UTC

Ron Weiner was thinking very hard :

OK Here is the “Least Crappy” solution I was able to conjure that ought
to work in every case. It involves a temp table that will get cleared
and filled each time you run the query. In my example I created a new
table “tblTempMonthDay” with just one column “Monthday” of a text(4)
type. I also made the “Monthday” column the Primary key

Then I created a the following VBA sub:

Public Sub BuildSql(dteStart As Date, dteEnd As Date)
Dim theDate As Date
CurrentDb.Execute "Delete * from tblTempMonthDay", dbFailOnError
theDate = dteStart
Do While theDate <= dteEnd
CurrentDb.Execute "Insert into tblTempMonthDay (Monthday)
Values('" & Format(theDate, "mmdd") & "')", dbFailOnError
theDate = DateAdd("d", 1, theDate)
Loop
End Sub

Then the query becomes a simple select with an In() clause like this:

SELECT RegDate, VIN
FROM tblVehicle
WHERE Format([regdate],"mmdd") In (Select Monthday from
tblTempMonthDay);

To make it all go, first call the sub with the Start and End Dates,
then run the query.

As I said this is a semi crappy way of doing this, but it should
supply the correct result under all conditions.

Rdub

Re: Need some SQL

<d4c943f9-430b-46cb-aaf2-767cec45dcf8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=502&group=comp.databases.ms-access#502

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:6214:324:: with SMTP id j4mr12760685qvu.34.1629056117513;
Sun, 15 Aug 2021 12:35:17 -0700 (PDT)
X-Received: by 2002:a05:6830:1d72:: with SMTP id l18mr10168766oti.264.1629056117264;
Sun, 15 Aug 2021 12:35:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ms-access
Date: Sun, 15 Aug 2021 12:35:17 -0700 (PDT)
In-Reply-To: <sfbngu$off$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=92.29.125.250; posting-account=SKIztwgAAAD15rYh-v-27VVmHult5LKY
NNTP-Posting-Host: 92.29.125.250
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me>
<sfbngu$off$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d4c943f9-430b-46cb-aaf2-767cec45dcf8n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Sun, 15 Aug 2021 19:35:17 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Keith Tizzard - Sun, 15 Aug 2021 19:35 UTC

Ron

I think this is getting close even with your qualifications.

I am fascinated by the amount of interest in what appears to be a deceptively simple problem.

Thank you for you contributions. I have yet to finalise a solution but will do so soon. It was not a test where I already knew the answer.

On Sunday, 15 August 2021 at 19:48:02 UTC+1, Ron Weiner wrote:
> Ron Weiner was thinking very hard :
>
> OK Here is the “Least Crappy” solution I was able to conjure that ought
> to work in every case. It involves a temp table that will get cleared
> and filled each time you run the query. In my example I created a new
> table “tblTempMonthDay” with just one column “Monthday” of a text(4)
> type. I also made the “Monthday” column the Primary key
>
> Then I created a the following VBA sub:
>
> Public Sub BuildSql(dteStart As Date, dteEnd As Date)
> Dim theDate As Date
> CurrentDb.Execute "Delete * from tblTempMonthDay", dbFailOnError
> theDate = dteStart
> Do While theDate <= dteEnd
> CurrentDb.Execute "Insert into tblTempMonthDay (Monthday)
> Values('" & Format(theDate, "mmdd") & "')", dbFailOnError
> theDate = DateAdd("d", 1, theDate)
> Loop
> End Sub
>
> Then the query becomes a simple select with an In() clause like this:
> SELECT RegDate, VIN
> FROM tblVehicle
> WHERE Format([regdate],"mmdd") In (Select Monthday from
> tblTempMonthDay);
>
> To make it all go, first call the sub with the Start and End Dates,
> then run the query.
>
> As I said this is a semi crappy way of doing this, but it should
> supply the correct result under all conditions.
>
> Rdub

Re: Need some SQL

<sfbv1n$7ao$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=503&group=comp.databases.ms-access#503

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nei...@myplaceofwork.com (Neil)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Sun, 15 Aug 2021 16:56:24 -0400
Organization: A noiseless patient Spider
Lines: 75
Message-ID: <sfbv1n$7ao$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me>
<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me>
<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
<sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me>
<sfbb72$9al$1@dont-email.me> <sfbdth$1kd$1@dont-email.me>
<sfbhf1$7ei$1@dont-email.me> <sfbijg$tjn$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 15 Aug 2021 20:56:23 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="195470b2d79895a17d789a32d94a9d22";
logging-data="7512"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+g3lr7RuGO+rtvKcd/1PcpbyfpW6f76x0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:rvVMkxxydplex/zkH4nlZjEor7M=
In-Reply-To: <sfbijg$tjn$1@dont-email.me>
Content-Language: en-US
 by: Neil - Sun, 15 Aug 2021 20:56 UTC

On 8/15/2021 1:23 PM, Ron Weiner wrote:
> Neil has brought this to us :
>> On 8/15/2021 12:03 PM, Ron Weiner wrote:
>>> It happens that Neil formulated :
>>>> On 8/15/2021 10:54 AM, Neil wrote:
>>>>> If I understand it, the year is not a factor, just the day and
>>>>> month. If so, the search could be structured:
>>>>>
>>>>> WHERE Day >= 7 AND Month >= 11 AND Day <= 14 AND Month <= 1*
>>>>>
>>>>> *This allows for Month <= 3, etc.
>>>>>
>>>>> Neil
>>>>>
>>>> OOPS! Wrote this before finishing my coffee!
>>>>
>>>> The structure should be:
>>>> WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1*
>>>>
>>>> -- best regards,
>>>>
>>>> Neil
>>>
>>> Sorry Neil, I am afraid you are going to need more coffee. The
>>> following Sql (I believe) uses the Where Clause you suggested.
>>>
>>> SELECT RegDate, VIN
>>> FROM tblVehicle
>>> WHERE (((Month([regdate]))>=11) AND ((Day([regDate]))>=7))
>>> OR (((Month([regdate]))<=1) AND ((Day([regDate]))<=14));
>>>
>>> Returns:
>>>
>>> RegDate        VIN
>>> 11/8/2001    235
>>> 12/12/2001    321
>>> 12/21/2019    665
>>> 1/12/2011    215
>>>
>>> The expected result is:
>>>
>>> RegDate        VIN
>>> 11/8/2001    235
>>> 12/3/2017    332
>>> 12/12/2001    321
>>> 12/21/2019    665
>>> 1/12/2011    215
>>>
>>> Rdub
>>
>> Since #332, falling in March, doesn't fit the parameters why is that
>> expected to be included in the inquiry?
>>
>> --
>> best regards,
>>
>> Neil
> I live in the land of Feet, Inches, Pounds and Ounces, and we do dates
> here in the form of Month / Day / Year.  So #332 is Dec 3rd (in my
> world) which does fit into the parameters.  Sorry for the confusion.
>
> I guess this is just another example of why a significant percentage of
> the people living in USA are totally F'n NUTS.  I don’t even want to get
> into COVID vaccination hesitancy, universal healthcare, or voting
> rights.  These days it's really getting hard to live here.  Very sad!
>
> Rdub

I, too, live in the land of unique measurements and dates. The giveaway
for me is that there isn't a month greater than 12 in anyone's calendar.

--
best regards,

Neil

Re: Need some SQL

<sfc01p$q0l$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=504&group=comp.databases.ms-access#504

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: rw...@domain.com (Ron Weiner)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Sun, 15 Aug 2021 17:13:27 -0400
Organization: WorksRite
Lines: 84
Message-ID: <sfc01p$q0l$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com> <sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com> <sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com> <sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1> <8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me> <sfbb72$9al$1@dont-email.me> <sfbdth$1kd$1@dont-email.me> <sfbhf1$7ei$1@dont-email.me> <sfbijg$tjn$1@dont-email.me> <sfbv1n$7ao$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Aug 2021 21:13:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1b76ae08641c2632c06c7d414a24e61d";
logging-data="26645"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VaFpvLs6nANWDamkqNFnU"
Cancel-Lock: sha1:IEo9RwU7G9w45SM64f/jMCMVRqU=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210815-4, 8/15/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Sun, 15 Aug 2021 21:13 UTC

Neil pretended :
> On 8/15/2021 1:23 PM, Ron Weiner wrote:
>> Neil has brought this to us :
>>> On 8/15/2021 12:03 PM, Ron Weiner wrote:
>>>> It happens that Neil formulated :
>>>>> On 8/15/2021 10:54 AM, Neil wrote:
>>>>>> If I understand it, the year is not a factor, just the day and month.
>>>>>> If so, the search could be structured:
>>>>>>
>>>>>> WHERE Day >= 7 AND Month >= 11 AND Day <= 14 AND Month <= 1*
>>>>>>
>>>>>> *This allows for Month <= 3, etc.
>>>>>>
>>>>>> Neil
>>>>>>
>>>>> OOPS! Wrote this before finishing my coffee!
>>>>>
>>>>> The structure should be:
>>>>> WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1*
>>>>>
>>>>> -- best regards,
>>>>>
>>>>> Neil
>>>>
>>>> Sorry Neil, I am afraid you are going to need more coffee. The following
>>>> Sql (I believe) uses the Where Clause you suggested.
>>>>
>>>> SELECT RegDate, VIN
>>>> FROM tblVehicle
>>>> WHERE (((Month([regdate]))>=11) AND ((Day([regDate]))>=7))
>>>> OR (((Month([regdate]))<=1) AND ((Day([regDate]))<=14));
>>>>
>>>> Returns:
>>>>
>>>> RegDate        VIN
>>>> 11/8/2001    235
>>>> 12/12/2001    321
>>>> 12/21/2019    665
>>>> 1/12/2011    215
>>>>
>>>> The expected result is:
>>>>
>>>> RegDate        VIN
>>>> 11/8/2001    235
>>>> 12/3/2017    332
>>>> 12/12/2001    321
>>>> 12/21/2019    665
>>>> 1/12/2011    215
>>>>
>>>> Rdub
>>>
>>> Since #332, falling in March, doesn't fit the parameters why is that
>>> expected to be included in the inquiry?
>>>
>>> -- best regards,
>>>
>>> Neil
>> I live in the land of Feet, Inches, Pounds and Ounces, and we do dates here
>> in the form of Month / Day / Year.  So #332 is Dec 3rd (in my world) which
>> does fit into the parameters.  Sorry for the confusion.
>>
>> I guess this is just another example of why a significant percentage of the
>> people living in USA are totally F'n NUTS.  I don’t even want to get into
>> COVID vaccination hesitancy, universal healthcare, or voting rights.  These
>> days it's really getting hard to live here.  Very sad!
>>
>> Rdub
>
> I, too, live in the land of unique measurements and dates. The giveaway for
> me is that there isn't a month greater than 12 in anyone's calendar.
>
> --
> best regards,
>
> Neil

RE: there isn't a month greater than 12 in anyone's calendar.

Ummm... That that is not exactly 100% true. There are several
calendars that have or periodically add a 13 month to keep it in sync
with planetary bodies. The Ethiopian and Hebrew calendars are
examples.

Rdub

Re: Need some SQL

<sfe67o$i03$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=508&group=comp.databases.ms-access#508

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nei...@myplaceofwork.com (Neil)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Mon, 16 Aug 2021 13:11:23 -0400
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <sfe67o$i03$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me>
<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me>
<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
<sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me>
<sfbb72$9al$1@dont-email.me> <sfbdth$1kd$1@dont-email.me>
<sfbhf1$7ei$1@dont-email.me> <sfbijg$tjn$1@dont-email.me>
<sfbv1n$7ao$1@dont-email.me> <sfc01p$q0l$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 16 Aug 2021 17:11:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="76ef61937c307b2339665cbbca585782";
logging-data="18435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RPbwraP/pgcGAUGs15CsNjH2FgYjrO+E="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:NDsWCHvpubHJh4JrVfkQn76H9Fo=
In-Reply-To: <sfc01p$q0l$1@dont-email.me>
Content-Language: en-US
 by: Neil - Mon, 16 Aug 2021 17:11 UTC

On 8/15/2021 5:13 PM, Ron Weiner wrote:
> Neil pretended :
>>
>> I, too, live in the land of unique measurements and dates. The
>> giveaway for me is that there isn't a month greater than 12 in
>> anyone's calendar.
>>
>> --
>> best regards,
>>
>> Neil
>
> RE: there isn't a month greater than 12 in anyone's calendar.
>
> Ummm... That that is not exactly 100% true.  There are several calendars
> that have or periodically add a 13 month to keep it in sync with
> planetary bodies.  The Ethiopian and Hebrew calendars are examples.
>
> Rdub
>
Thanks for the reminder... fortunately, my SELECT approach would handle
those, too!

--
best regards,

Neil

Re: Need some SQL

<0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=509&group=comp.databases.ms-access#509

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:6214:570:: with SMTP id cj16mr17594655qvb.41.1629137777042;
Mon, 16 Aug 2021 11:16:17 -0700 (PDT)
X-Received: by 2002:aca:e106:: with SMTP id y6mr50713oig.62.1629137776736;
Mon, 16 Aug 2021 11:16:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ms-access
Date: Mon, 16 Aug 2021 11:16:16 -0700 (PDT)
In-Reply-To: <sfbb72$9al$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=92.29.125.250; posting-account=SKIztwgAAAD15rYh-v-27VVmHult5LKY
NNTP-Posting-Host: 92.29.125.250
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me>
<sfb9r9$hlb$1@dont-email.me> <sfbb72$9al$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Mon, 16 Aug 2021 18:16:17 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Keith Tizzard - Mon, 16 Aug 2021 18:16 UTC

Neil

I thought I had replied to your post earlier but cannot find it.

You propose the condition

The structure should be:
WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1

This would not select the first 6 days of December.

For example consider 2 December. 2 is not >=7 so that part fails; and 12 (December) is not <=1 so that part fails

On Sunday, 15 August 2021 at 16:17:59 UTC+1, Neil wrote:
> On 8/15/2021 10:54 AM, Neil wrote:
> > If I understand it, the year is not a factor, just the day and month. If
> > so, the search could be structured:
> >
> > WHERE Day >= 7 AND Month >= 11 AND Day <= 14 AND Month <= 1*
> >
> > *This allows for Month <= 3, etc.
> >
> > Neil
> >
> OOPS! Wrote this before finishing my coffee!
>
> The structure should be:
> WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1*
>
> --
> best regards,
>
> Neil

Re: Need some SQL

<sfect4$458$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=510&group=comp.databases.ms-access#510

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nei...@myplaceofwork.com (Neil)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Mon, 16 Aug 2021 15:05:08 -0400
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <sfect4$458$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me>
<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me>
<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
<sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me>
<sfbb72$9al$1@dont-email.me>
<0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 16 Aug 2021 19:05:09 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="76ef61937c307b2339665cbbca585782";
logging-data="4264"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1838kyCe1IQ0vUFSYVlZvmY8gGFTi/ZfjQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:i6ssxmX9B2nwFL+pbILW9QH+q6M=
In-Reply-To: <0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
Content-Language: en-US
 by: Neil - Mon, 16 Aug 2021 19:05 UTC

On 8/16/2021 2:16 PM, Keith Tizzard wrote:
> Neil
>
> I thought I had replied to your post earlier but cannot find it.
>
> You propose the condition
>
> The structure should be:
> WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1
>
> This would not select the first 6 days of December.
>
> For example consider 2 December. 2 is not >=7 so that part fails; and 12 (December) is not <=1 so that part fails
>
>
[...]

I was responding to the parameters you laid out on Aug. 15:

"I have a table of vehicle details
VehicleID, RegDate

123, 2/11/2009
234, 4/11/2014
235, 8/11/2001

332, 3/12/2017
321, 12/12/2001
665, 21/12/2019
215, 12/1/2011
762, 17/1/2003
392, 23/1/2005"

and a follow-up post on the same day:

"I want to find those vehicles whose RegDate anniversary (not the
Regdate itself) falls between 7/11/2020 and 14/1/2021"

Your date format is Day, Month, Year, defined by records 665 and 762,
and 392. Therefore, record 332 is December 3rd.

Since December is month 12, it is ">=" November, month 11. If you are
not getting the correct results when running the query, some other
factor is intervening in the process.

--
best regards,

Neil

Re: Need some SQL

<sfef9r$kg6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=511&group=comp.databases.ms-access#511

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nei...@myplaceofwork.com (Neil)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Mon, 16 Aug 2021 15:46:04 -0400
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <sfef9r$kg6$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me>
<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me>
<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
<sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me>
<sfbb72$9al$1@dont-email.me>
<0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
<sfect4$458$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 16 Aug 2021 19:46:03 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="76ef61937c307b2339665cbbca585782";
logging-data="20998"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187+LXiaHEvLhXYcQQBes8aUcytgjcN4v8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:64kgYdkK/V9g86goAoUX8t4s85s=
In-Reply-To: <sfect4$458$1@dont-email.me>
Content-Language: en-US
 by: Neil - Mon, 16 Aug 2021 19:46 UTC

On 8/16/2021 3:05 PM, Neil wrote:
> On 8/16/2021 2:16 PM, Keith Tizzard wrote:
>> Neil
>>
>> I thought I had replied to your post earlier but cannot find it.
>>
>> You propose the condition
>>
>> The structure should be:
>> WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1
>>
>> This would not select the first 6 days of December.
>>
>> For example consider 2 December.  2 is not >=7  so that part fails;
>> and 12 (December) is not <=1  so that part fails
>>
>>
> [...]
>
> I was responding to the parameters you laid out on Aug. 15:
>
> "I have a table of vehicle details
> VehicleID, RegDate
>
> 123, 2/11/2009
> 234, 4/11/2014
> 235, 8/11/2001
>
>
> 332, 3/12/2017
> 321, 12/12/2001
> 665, 21/12/2019
> 215, 12/1/2011
> 762, 17/1/2003
> 392, 23/1/2005"
>
> and a follow-up post on the same day:
>
> "I want to find those vehicles whose RegDate anniversary (not the
> Regdate itself) falls between  7/11/2020 and 14/1/2021"
>
> Your date format is Day, Month, Year, defined by records 665 and 762,
> and 392. Therefore, record 332 is December 3rd.
>
> Since December is month 12, it is ">=" November, month 11. If you are
> not getting the correct results when running the query, some other
> factor is intervening in the process.
>
Forget all I wrote above!

The problem with my suggested query is that the Day parameter (>= 7)
will not correctly select any records with days less than 7, regardless
of month. So, it needs to be expanded:

WHERE Day >= 7 AND Month = 11
OR Month > 11
OR Day <= 14 AND Month = 1
OR Month < 1

Again, if you are looking for records in March, for example, the above
would work.

--
best regards,

Neil

Re: Need some SQL

<9ca91ce3-8cdf-4762-8686-cc591c1da0f9n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=512&group=comp.databases.ms-access#512

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:620a:14b1:: with SMTP id x17mr475158qkj.37.1629150714719;
Mon, 16 Aug 2021 14:51:54 -0700 (PDT)
X-Received: by 2002:aca:d06:: with SMTP id 6mr12351oin.105.1629150714398; Mon,
16 Aug 2021 14:51:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ms-access
Date: Mon, 16 Aug 2021 14:51:54 -0700 (PDT)
In-Reply-To: <sfef9r$kg6$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=92.29.125.250; posting-account=SKIztwgAAAD15rYh-v-27VVmHult5LKY
NNTP-Posting-Host: 92.29.125.250
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me>
<sfb9r9$hlb$1@dont-email.me> <sfbb72$9al$1@dont-email.me> <0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
<sfect4$458$1@dont-email.me> <sfef9r$kg6$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9ca91ce3-8cdf-4762-8686-cc591c1da0f9n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Mon, 16 Aug 2021 21:51:54 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Keith Tizzard - Mon, 16 Aug 2021 21:51 UTC

The condition needs to work for any StartDate and EndDate. An earlier suggestion worked when they were both in the same year but not in different years.

I just gave one possible example of 7 Nov and 14 January where your condition works. However is does not work when the dates are in the same year.

For example 10 April 2020 to 21 September 2020, your condition becomes

Day >=10 And Month = 4
Or Month >4
Or Day <=21 And Month=9
Or Month<9

Month>4 Or Month<9 covers the whole year !

Tricky isn't it.

On Monday, 16 August 2021 at 20:46:07 UTC+1, Neil wrote:
> On 8/16/2021 3:05 PM, Neil wrote:
> > On 8/16/2021 2:16 PM, Keith Tizzard wrote:
> >> Neil
> >>
> >> I thought I had replied to your post earlier but cannot find it.
> >>
> >> You propose the condition
> >>
> >> The structure should be:
> >> WHERE Day >= 7 AND Month >= 11 OR Day <= 14 AND Month <= 1
> >>
> >> This would not select the first 6 days of December.
> >>
> >> For example consider 2 December. 2 is not >=7 so that part fails;
> >> and 12 (December) is not <=1 so that part fails
> >>
> >>
> > [...]
> >
> > I was responding to the parameters you laid out on Aug. 15:
> >
> > "I have a table of vehicle details
> > VehicleID, RegDate
> >
> > 123, 2/11/2009
> > 234, 4/11/2014
> > 235, 8/11/2001
> >
> >
> > 332, 3/12/2017
> > 321, 12/12/2001
> > 665, 21/12/2019
> > 215, 12/1/2011
> > 762, 17/1/2003
> > 392, 23/1/2005"
> >
> > and a follow-up post on the same day:
> >
> > "I want to find those vehicles whose RegDate anniversary (not the
> > Regdate itself) falls between 7/11/2020 and 14/1/2021"
> >
> > Your date format is Day, Month, Year, defined by records 665 and 762,
> > and 392. Therefore, record 332 is December 3rd.
> >
> > Since December is month 12, it is ">=" November, month 11. If you are
> > not getting the correct results when running the query, some other
> > factor is intervening in the process.
> >
> Forget all I wrote above!
>
> The problem with my suggested query is that the Day parameter (>= 7)
> will not correctly select any records with days less than 7, regardless
> of month. So, it needs to be expanded:
> WHERE Day >= 7 AND Month = 11
> OR Month > 11
> OR Day <= 14 AND Month = 1
> OR Month < 1
>
> Again, if you are looking for records in March, for example, the above
> would work.
>
> --
> best regards,
>
> Neil

Re: Need some SQL

<sfeus9$rij$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=513&group=comp.databases.ms-access#513

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nei...@myplaceofwork.com (Neil)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Mon, 16 Aug 2021 20:11:53 -0400
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <sfeus9$rij$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me>
<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me>
<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
<sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me>
<sfbb72$9al$1@dont-email.me>
<0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
<sfect4$458$1@dont-email.me> <sfef9r$kg6$1@dont-email.me>
<9ca91ce3-8cdf-4762-8686-cc591c1da0f9n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 17 Aug 2021 00:11:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b0426bb0e9d050dea3a4b9e46756458d";
logging-data="28243"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+aFuMmufTyP09z7NW1OXmWrb/dQ8h+pU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:xpJz+kyvDZsUQcicaZo34OVv/pI=
In-Reply-To: <9ca91ce3-8cdf-4762-8686-cc591c1da0f9n@googlegroups.com>
Content-Language: en-US
 by: Neil - Tue, 17 Aug 2021 00:11 UTC

On 8/16/2021 5:51 PM, Keith Tizzard wrote:
> The condition needs to work for any StartDate and EndDate. An earlier suggestion worked when they were both in the same year but not in different years.
>
> I just gave one possible example of 7 Nov and 14 January where your condition works. However is does not work when the dates are in the same year.
>
> For example 10 April 2020 to 21 September 2020, your condition becomes
>
> Day >=10 And Month = 4
> Or Month >4
> Or Day <=21 And Month=9
> Or Month<9
>
> Month>4 Or Month<9 covers the whole year !
>
> Tricky isn't it.
>
[...]

Good point. Parameterize the date ranges just to keep the query
relatively simple. For example:

StartDate = Day >= 10 and Month = 4
EndDate = 21 and Month = 9
MonthRange = Month > 4 AND Month < 9

SELECT *
WHERE RecDate = StartDate
OR RecDate = MonthRange
OR RecDate = EndDate

--
best regards,

Neil

Re: Need some SQL

<sff4t2$ssd$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=514&group=comp.databases.ms-access#514

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nei...@myplaceofwork.com (Neil)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Mon, 16 Aug 2021 21:54:45 -0400
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <sff4t2$ssd$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me>
<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me>
<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
<sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me>
<sfbb72$9al$1@dont-email.me>
<0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
<sfect4$458$1@dont-email.me> <sfef9r$kg6$1@dont-email.me>
<9ca91ce3-8cdf-4762-8686-cc591c1da0f9n@googlegroups.com>
<sfeus9$rij$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 17 Aug 2021 01:54:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b0426bb0e9d050dea3a4b9e46756458d";
logging-data="29581"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Af7brekT8F9VgpfuIquFhJ4z6UFI4jCg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:ciSPOq9hByxRPCjx49/JCfNCstY=
In-Reply-To: <sfeus9$rij$1@dont-email.me>
Content-Language: en-US
 by: Neil - Tue, 17 Aug 2021 01:54 UTC

On 8/16/2021 8:11 PM, Neil wrote:
> On 8/16/2021 5:51 PM, Keith Tizzard wrote:
>> The condition needs to work for any StartDate and EndDate.  An earlier
>> suggestion worked when they were both in the same year but not in
>> different years.
>>
>> I just gave one possible example of 7 Nov and 14 January where your
>> condition works.  However is does not work when the dates are in the
>> same year.
>>
>> For example 10 April 2020 to 21 September 2020, your condition becomes
>>
>> Day >=10 And Month = 4
>> Or Month >4
>> Or Day <=21 And Month=9
>> Or Month<9
>>
>> Month>4 Or Month<9 covers the whole year !
>>
>> Tricky isn't it.
>>
> [...]
>
> Good point. Parameterize the date ranges just to keep the query
> relatively simple. For example:
>
> StartDate = Day >= 10 and Month = 4
> EndDate = 21 and Month = 9
> MonthRange = Month > 4 AND Month < 9
>
> SELECT *
> WHERE RecDate = StartDate
> OR RecDate = MonthRange
> OR RecDate = EndDate
>
>
Or just modify the SQL to:

WHERE
Day >=10 AND Month = 4
OR Month >4 AND Month <9
OR Day <=21 AND Month=9

For dates across years:

WHERE
Day >=7 AND Month = 11
OR Month >11 AND Month <1
OR Day <=14 AND Month=1

--
best regards,

Neil

Re: Need some SQL

<sffm8i$hgh$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=515&group=comp.databases.ms-access#515

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: nei...@myplaceofwork.com (Neil)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Tue, 17 Aug 2021 02:50:58 -0400
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <sffm8i$hgh$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<sf67th$avh$1@dont-email.me>
<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
<sf8kdt$hu$1@dont-email.me>
<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
<sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
<sfb4nj$f2v$1@dont-email.me> <sfb9r9$hlb$1@dont-email.me>
<sfbb72$9al$1@dont-email.me>
<0d6fc0ec-3dba-40e2-bf16-66dddb98566dn@googlegroups.com>
<sfect4$458$1@dont-email.me> <sfef9r$kg6$1@dont-email.me>
<9ca91ce3-8cdf-4762-8686-cc591c1da0f9n@googlegroups.com>
<sfeus9$rij$1@dont-email.me> <sff4t2$ssd$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 17 Aug 2021 06:50:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b0426bb0e9d050dea3a4b9e46756458d";
logging-data="17937"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/B0QFB1VfQ/bN1NnGytCq2By75MEeU2Ls="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:SP0oZHo/dprv52XhOEniLU++ekQ=
In-Reply-To: <sff4t2$ssd$1@dont-email.me>
Content-Language: en-US
 by: Neil - Tue, 17 Aug 2021 06:50 UTC

Thanks to all for putting up with my "thinking out loud" about this!

I think a modification to the parameterized version may work (obviously,
this is about the concept, not the specific code).

(example within same year)
StartDate = Day >= 10 and Month = 4
EndDate = Day <= 21 and Month = 9

(example across years)
StartDate = Day >= 7 and Month = 11
EndDate = Day <= 14 and Month = 1

IF Month(StartDate) < Month(EndDate) THEN
MonthRange = > Month(StartDate) AND < Month(EndDate)
ELSE
MonthRange = > Month(StartDate) OR < Month(EndDate)
END IF

SELECT *
WHERE RecDate = StartDate
OR RecDate = MonthRange
OR RecDate = EndDate

Going back to bed now...

--
best regards,

Neil

Re: Need some SQL

<XnsAD896874E16EEammammatatiscalineti@127.0.0.1>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=516&group=comp.databases.ms-access#516

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: ammamm...@tiscalinet.it (Ammammata)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Tue, 17 Aug 2021 08:16:07 -0000 (UTC)
Message-ID: <XnsAD896874E16EEammammatatiscalineti@127.0.0.1>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com> <sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com> <sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com> <sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1> <8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me> <sfbngu$off$1@dont-email.me> <d4c943f9-430b-46cb-aaf2-767cec45dcf8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 17 Aug 2021 08:16:07 -0000 (UTC)
Injection-Info: solani.org;
logging-data="27553"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Xnews/??.01.30 Mime-proxy/2.3.c.1 (Win32)
Cancel-Lock: sha1:c+D+Bx+9+Ez50NovK+6aQZ9ocQI=
X-Face: s5/Tl9"^@"z`/]&NeE,Wl.^B~E2x9PA?1n:XZq2^T2Prz*},H~M'2.*@~v9MXx|OL8<EqC0MU$v+`Pu;`eq$N12\Nc*)cp$iBgD/wysO=)P%n6)\Xf}L\E$-0s\mD::Dx\6QwNh<U!LBH1Xj(=zy?OV.|=]We",DS\6[:
X-User-ID: eJwNxMkBwDAIA7CVgGKOceIS9h+h1UN4QuNND4Rjsc45VZGYZRmVOKAXA91oNjSjukQIQaXMn+Wetmm/dj9CDxSf
 by: Ammammata - Tue, 17 Aug 2021 08:16 UTC

Il giorno Sun 15 Aug 2021 09:35:17p, *Keith Tizzard* ha inviato su
comp.databases.ms-access il messaggio
news:d4c943f9-430b-46cb-aaf2-767cec45dcf8n@googlegroups.com. Vediamo
cosa ha scritto:

>
> I am fascinated by the amount of interest in what appears to be a
> deceptively simple problem.
>
> Thank you for you contributions.

I asked about your problem also on an italian access newsgroup

Subject: Re: filtrare date senza tenere conto dell'anno
Newsgroups: it.comp.appl.access

the "final" query they suggested is like this:

*remove* year from date and convert day/month into a single number, i.e.
month * 100 + day

if start-month > end-month then

select from start-date to 31/dec
*union*
select from 01/jan to end-date

else
normal select between start-date and end-date
end if

--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
............ [ al lavoro ] ...........

Re: Need some SQL

<509be94e-a6c3-46b9-8c94-3e4efb49b1b7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=517&group=comp.databases.ms-access#517

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:ac8:7f01:: with SMTP id f1mr12036434qtk.362.1629365160567;
Thu, 19 Aug 2021 02:26:00 -0700 (PDT)
X-Received: by 2002:a05:6808:f8e:: with SMTP id o14mr1889655oiw.34.1629365160289;
Thu, 19 Aug 2021 02:26:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ms-access
Date: Thu, 19 Aug 2021 02:26:00 -0700 (PDT)
In-Reply-To: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23c5:f196:2601:a56a:bb4a:c0f1:fea6;
posting-account=kPm-FwoAAAD0MX_g8dnNmexZ6gEyJcrj
NNTP-Posting-Host: 2a00:23c5:f196:2601:a56a:bb4a:c0f1:fea6
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <509be94e-a6c3-46b9-8c94-3e4efb49b1b7n@googlegroups.com>
Subject: Re: Need some SQL
From: mikewpa...@tiscali.co.uk (Mike P)
Injection-Date: Thu, 19 Aug 2021 09:26:00 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Mike P - Thu, 19 Aug 2021 09:26 UTC

Have you thought about a User Defined Function to determine the anniversary of the registration date?
Something like:

Function GetAnniversary(varRegDate As Variant)
Dim bytCounter As Byte
Dim datAnniversary As Date
If IsNull(varRegDate) Then Exit Function
If Not IsDate(varRegDate) Then Exit Function
If varRegDate >= Date Then GetAnniversary = varRegDate: Exit Function
datAnniversary = varRegDate
For bytCounter = 1 To 99
datAnniversary = DateAdd("yyyy", 1, datAnniversary)
If datAnniversary >= Date Then GetAnniversary = datAnniversary: Exit Function
Next bytCounter
MsgBox "Subscript out of range."
End Function

Then the where clause in the SQL would be
where GetAnniversary(RegDate) between [startdate] and [enddate]
using startdate and enddate parameters

Mike P
19/8/21

Re: Need some SQL

<sfmih4$bau$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=518&group=comp.databases.ms-access#518

  copy link   Newsgroups: comp.databases.ms-access
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: rw...@domain.com (Ron Weiner)
Newsgroups: comp.databases.ms-access
Subject: Re: Need some SQL
Date: Thu, 19 Aug 2021 17:30:10 -0400
Organization: WorksRite
Lines: 114
Message-ID: <sfmih4$bau$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com> <sf67th$avh$1@dont-email.me> <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com> <sf8kdt$hu$1@dont-email.me> <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com> <sf8r5q$1ul$1@dont-email.me> <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1> <8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com> <sfb4nj$f2v$1@dont-email.me> <sfbngu$off$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 19 Aug 2021 21:30:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f89c6f6fd87f9af2576b11e12ecfc43e";
logging-data="11614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18yh5vcNEcaZfEtVVr8Ki75"
Cancel-Lock: sha1:4gpZAcfFUAwOEBXBu4YpksfmvGE=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210819-8, 8/19/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Thu, 19 Aug 2021 21:30 UTC

Ron Weiner submitted this idea :
I am sure that by now you are sicka and tired of my solutions to your
non trivial problem. But hang in there with me One More Time. Finally
here is an ALL SQL way of doing this without any VBA code at all.

The only catch is that you need to add one additional permanent table
to your database, a Nums Table. This is a table with only one column,
Num that contains an integer number from 0 to the highest number that
you are ever likely to need. You would make this table just one time,
AND you can make it in a New York second with the following make table
query that makes use of the Union and Cartiesan Product Join.

SELECT (Ones.N+Tens.N+Huns.N+Thous.N) AS Num INTO tblNums
FROM (Select 0 as N From MSysQueries
Union Select 1 From MSysQueries
Union Select 2 From MSysQueries
Union Select 3 From MSysQueries
Union Select 4 From MSysQueries
Union Select 5 From MSysQueries
Union Select 6 From MSysQueries
Union Select 7 From MSysQueries
Union Select 8 From MSysQueries
Union Select 9 From MSysQueries) AS Ones, (Select 0 as N From
MSysQueries
Union Select 10 From MSysQueries
Union Select 20 From MSysQueries
Union Select 30 From MSysQueries
Union Select 40 From MSysQueries
Union Select 50 From MSysQueries
Union Select 60 From MSysQueries
Union Select 70 From MSysQueries
Union Select 80 From MSysQueries
Union Select 90 From MSysQueries) AS Tens, (Select 0 as N From
MSysQueries
Union Select 100 From MSysQueries
Union Select 200 From MSysQueries
Union Select 300 From MSysQueries
Union Select 400 From MSysQueries
Union Select 500 From MSysQueries
Union Select 600 From MSysQueries
Union Select 700 From MSysQueries
Union Select 800 From MSysQueries
Union Select 900 From MSysQueries) AS Huns, (Select 0 as N From
MSysQueries
Union Select 1000 From MSysQueries
Union Select 2000 From MSysQueries
Union Select 3000 From MSysQueries
Union Select 4000 From MSysQueries
Union Select 5000 From MSysQueries
Union Select 6000 From MSysQueries
Union Select 7000 From MSysQueries
Union Select 8000 From MSysQueries
Union Select 9000 From MSysQueries) AS Thous;

Te above sql will create a table "tblNums" and populate it with 10,000
rows 0 to 9999 in a split second.

Once this table has been added to your database then this simple query
will produce your result lickety split every time by just using the
Start and End dates a parameters.

SELECT VIN
FROM tblVehicle
WHERE Format([regdate],"mmdd") In
(
SELECT Format(DateAdd("d",[Num],#[StartDate]#),"mmdd") AS Dates
FROM tblNums
WHERE (((tblNums.Num)<DateDiff("d",#[StartDate]#,#[EndDate]#)+1))
ORDER BY tblNums.Num
);

I haven’t often found use for a nums table in my Access Applications,
but when you need to pull a number of rows out of thin air this is a
great technique. Sorry I did not think about this sooner.

I promise to leave you alone now that I have this out of my system.

Ron W

> Ron Weiner was thinking very hard :
>
> OK Here is the “Least Crappy” solution I was able to conjure that ought to
> work in every case. It involves a temp table that will get cleared and
> filled each time you run the query. In my example I created a new table
> “tblTempMonthDay” with just one column “Monthday” of a text(4) type. I also
> made the “Monthday” column the Primary key
>
> Then I created a the following VBA sub:
>
> Public Sub BuildSql(dteStart As Date, dteEnd As Date)
> Dim theDate As Date
> CurrentDb.Execute "Delete * from tblTempMonthDay", dbFailOnError
> theDate = dteStart
> Do While theDate <= dteEnd
> CurrentDb.Execute "Insert into tblTempMonthDay (Monthday) Values('" &
> Format(theDate, "mmdd") & "')", dbFailOnError
> theDate = DateAdd("d", 1, theDate)
> Loop
> End Sub
>
> Then the query becomes a simple select with an In() clause like this:
>
> SELECT RegDate, VIN
> FROM tblVehicle
> WHERE Format([regdate],"mmdd") In (Select Monthday from tblTempMonthDay);
>
> To make it all go, first call the sub with the Start and End Dates, then run
> the query.
>
> As I said this is a semi crappy way of doing this, but it should supply the
> correct result under all conditions.
>
> Rdub

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor