Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Consistency requires you to be as ignorant today as you were a year ago." -- Bernard Berenson


devel / comp.databases.ms-access / 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
Need some SQL

<f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:ac8:7b47:: with SMTP id m7mr1642512qtu.178.1628767642810;
Thu, 12 Aug 2021 04:27:22 -0700 (PDT)
X-Received: by 2002:a05:6808:f8e:: with SMTP id o14mr2864439oiw.34.1628767642511;
Thu, 12 Aug 2021 04:27:22 -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, 12 Aug 2021 04:27:22 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=92.29.125.250; posting-account=SKIztwgAAAD15rYh-v-27VVmHult5LKY
NNTP-Posting-Host: 92.29.125.250
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
Subject: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Thu, 12 Aug 2021 11:27:22 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Keith Tizzard - Thu, 12 Aug 2021 11:27 UTC

I have a table of vehicle registration dates with the relevant fields:
VehicleID, RegDate

Work needs to be carried out on a vehicle on the anniversary of its RegDate.

I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.

I may end up with:
223, 12/11/2008
334, 13/11/2013
345, 13/11/2020
444, 14/11/2017
....
393, 05/01/2009
998, 07/01/2003

Is there a simple SQL to achieve this?

Re: Need some SQL

<XnsAD849A7C6C706ammammatatiscalineti@127.0.0.1>

  copy mid

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

  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: Thu, 12 Aug 2021 13:11:07 -0000 (UTC)
Message-ID: <XnsAD849A7C6C706ammammatatiscalineti@127.0.0.1>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 12 Aug 2021 13:11:07 -0000 (UTC)
Injection-Info: solani.org;
logging-data="22675"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Xnews/??.01.30 Mime-proxy/2.3.c.1 (Win32)
Cancel-Lock: sha1:DX0TkUXLiGCMAa/9kGxQaJCyRhs=
X-User-ID: eJwNy8ERACEIA8CWDBjgymHQ9F/C+d5ZeiAmdzA2ReHKQdtqwqK4ho7bBUwZwk5blVbrZL/koncNlZ3P7fsBM4YUmg==
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[:
 by: Ammammata - Thu, 12 Aug 2021 13:11 UTC

Il giorno Thu 12 Aug 2021 01:27:22p, *Keith Tizzard* ha inviato su
comp.databases.ms-access il messaggio
news:f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com. Vediamo
cosa ha scritto:

> I need to find all the vehicles whose anniversary falls between two
> given dates. The date range may start in one year (say in November)
> and end in the next (say in February), or it may be solely in a single
> year.
>
> I may end up with:
> 223, 12/11/2008
> 334, 13/11/2013
> 345, 13/11/2020
> 444, 14/11/2017
> ...
> 393, 05/01/2009
> 998, 07/01/2003
>
> Is there a simple SQL to achieve this?
>

sorry, in just 10 minutes I couldn't do better than this, that's NOT
simple as you requested:

declare @fd as int -- from day
declare @fm as int -- from month

declare @td as int -- to day
declare @tm as int -- to month

declare @fr as int -- from range
declare @tr as int -- to range

set @fd = 15 -- i.e. from 15/10
set @fm = 10

set @td = 24 -- i.e. to 24/2
set @tm = 2

set @fr = @fm * 50 + @fd -- convert month and day into a single number
set @tr =
case -- case 'to' is lower then 'from' -> falls in next year
when @tm * 50 + @td < @fr then @tm * 50 + @td + 600
else @tm * 50 + @td
end

print @tr
print @fr

select DocNum, DocDate -- using ORDR SAP table ;)
from ORDR

where
case
when @tm * 50 + @td < @fr
and DATEPART(month, DocDate) * 50 + DATEPART(day, DocDate) < @fr
then DATEPART(month, DocDate) * 50 + DATEPART(day, DocDate) + 600
else DATEPART(month, DocDate) * 50 + DATEPART(day, DocDate)
End >= @fr
and
case
when @tm * 50 + @td < @fr
and DATEPART(month, DocDate) * 50 + DATEPART(day, DocDate) < @fr
then DATEPART(month, DocDate) * 50 + DATEPART(day, DocDate) + 600
else DATEPART(month, DocDate) * 50 + DATEPART(day, DocDate)
end <= @tr

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

Re: Need some SQL

<XnsAD849AB29BC90ammammatatiscalineti@127.0.0.1>

  copy mid

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

  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: Thu, 12 Aug 2021 13:12:22 -0000 (UTC)
Message-ID: <XnsAD849AB29BC90ammammatatiscalineti@127.0.0.1>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com> <XnsAD849A7C6C706ammammatatiscalineti@127.0.0.1>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 12 Aug 2021 13:12:22 -0000 (UTC)
Injection-Info: solani.org;
logging-data="22675"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Xnews/??.01.30 Mime-proxy/2.3.c.1 (Win32)
Cancel-Lock: sha1:V2y/LQ4l/0ppTOr947773YHdB4M=
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: eJwFwQERADEIAzBLPyjdIWcU8C/hk3Ae6oJBxMaeoh0961F/jUJfE0B7k4h29SWhyZwO24cvKj3Hdddq9QNpphZS
 by: Ammammata - Thu, 12 Aug 2021 13:12 UTC

Il giorno Thu 12 Aug 2021 03:11:07p, *Ammammata* ha inviato su
comp.databases.ms-access il messaggio
news:XnsAD849A7C6C706ammammatatiscalineti@127.0.0.1. Vediamo cosa ha
scritto:

> print @tr
> print @fr
>

remove ;)

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

Re: Need some SQL

<d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:622a:30d:: with SMTP id q13mr4304511qtw.147.1628781094598; Thu, 12 Aug 2021 08:11:34 -0700 (PDT)
X-Received: by 2002:a05:6808:14c2:: with SMTP id f2mr3750914oiw.29.1628781094242; Thu, 12 Aug 2021 08:11:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ms-access
Date: Thu, 12 Aug 2021 08:11:34 -0700 (PDT)
In-Reply-To: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.30.79.18; posting-account=RurhpQoAAACBjKrwaxvElRMdPO3AZiPP
NNTP-Posting-Host: 65.30.79.18
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com>
Subject: Re: Need some SQL
From: ron81...@gmail.com (Ron Paii)
Injection-Date: Thu, 12 Aug 2021 15:11:34 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 22
 by: Ron Paii - Thu, 12 Aug 2021 15:11 UTC

On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
> I have a table of vehicle registration dates with the relevant fields:
> VehicleID, RegDate
>
> Work needs to be carried out on a vehicle on the anniversary of its RegDate.
>
> I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.
>
> I may end up with:
> 223, 12/11/2008
> 334, 13/11/2013
> 345, 13/11/2020
> 444, 14/11/2017
> ...
> 393, 05/01/2009
> 998, 07/01/2003
>
> Is there a simple SQL to achieve this?

PARAMETERS DateStart DateTime, DateEnd DateTime;
SELECT tblReg.ID, tblReg.RegDate
FROM tblReg
WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);

Re: Need some SQL

<0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:6214:3001:: with SMTP id ke1mr4415056qvb.52.1628781209951;
Thu, 12 Aug 2021 08:13:29 -0700 (PDT)
X-Received: by 2002:a05:6808:f8e:: with SMTP id o14mr3621113oiw.34.1628781209800;
Thu, 12 Aug 2021 08:13:29 -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, 12 Aug 2021 08:13:29 -0700 (PDT)
In-Reply-To: <d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.30.79.18; posting-account=RurhpQoAAACBjKrwaxvElRMdPO3AZiPP
NNTP-Posting-Host: 65.30.79.18
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com> <d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
Subject: Re: Need some SQL
From: ron81...@gmail.com (Ron Paii)
Injection-Date: Thu, 12 Aug 2021 15:13:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Ron Paii - Thu, 12 Aug 2021 15:13 UTC

On Thursday, August 12, 2021 at 10:11:37 AM UTC-5, Ron Paii wrote:
> On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
> > I have a table of vehicle registration dates with the relevant fields:
> > VehicleID, RegDate
> >
> > Work needs to be carried out on a vehicle on the anniversary of its RegDate.
> >
> > I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.
> >
> > I may end up with:
> > 223, 12/11/2008
> > 334, 13/11/2013
> > 345, 13/11/2020
> > 444, 14/11/2017
> > ...
> > 393, 05/01/2009
> > 998, 07/01/2003
> >
> > Is there a simple SQL to achieve this?
> PARAMETERS DateStart DateTime, DateEnd DateTime;
> SELECT tblReg.ID, tblReg.RegDate
> FROM tblReg
> WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);

Add DateValue to end date

PARAMETERS DateStart DateTime, DateEnd DateTime;
SELECT tblReg.ID, tblReg.RegDate
FROM tblReg
WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,DateValue([DateEnd]));

Re: Need some SQL

<682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:620a:15ad:: with SMTP id f13mr5209262qkk.0.1628781604305;
Thu, 12 Aug 2021 08:20:04 -0700 (PDT)
X-Received: by 2002:a9d:640e:: with SMTP id h14mr3731796otl.119.1628781603633;
Thu, 12 Aug 2021 08:20:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!fdn.fr!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, 12 Aug 2021 08:20:03 -0700 (PDT)
In-Reply-To: <0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
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>
<d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com> <0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Thu, 12 Aug 2021 15:20:04 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Keith Tizzard - Thu, 12 Aug 2021 15:20 UTC

Ron, that selects Reg dates between start and end. I need the anniversary dates to be in the date range. The reg dates will be a number of years earlier

On Thursday, 12 August 2021 at 16:13:32 UTC+1, Ron Paii wrote:
> On Thursday, August 12, 2021 at 10:11:37 AM UTC-5, Ron Paii wrote:
> > On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
> > > I have a table of vehicle registration dates with the relevant fields:
> > > VehicleID, RegDate
> > >
> > > Work needs to be carried out on a vehicle on the anniversary of its RegDate.
> > >
> > > I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.
> > >
> > > I may end up with:
> > > 223, 12/11/2008
> > > 334, 13/11/2013
> > > 345, 13/11/2020
> > > 444, 14/11/2017
> > > ...
> > > 393, 05/01/2009
> > > 998, 07/01/2003
> > >
> > > Is there a simple SQL to achieve this?
> > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > SELECT tblReg.ID, tblReg.RegDate
> > FROM tblReg
> > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);
> Add DateValue to end date
> PARAMETERS DateStart DateTime, DateEnd DateTime;
> SELECT tblReg.ID, tblReg.RegDate
> FROM tblReg
> WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,DateValue([DateEnd]));

Re: Need some SQL

<d546d523-80a5-44f4-b0b0-1aed4463379fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:6214:3b1:: with SMTP id m17mr5138891qvy.60.1628789830307;
Thu, 12 Aug 2021 10:37:10 -0700 (PDT)
X-Received: by 2002:a05:6808:14cf:: with SMTP id f15mr7229309oiw.145.1628789830116;
Thu, 12 Aug 2021 10:37:10 -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, 12 Aug 2021 10:37:09 -0700 (PDT)
In-Reply-To: <682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.30.79.18; posting-account=RurhpQoAAACBjKrwaxvElRMdPO3AZiPP
NNTP-Posting-Host: 65.30.79.18
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com> <0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
<682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d546d523-80a5-44f4-b0b0-1aed4463379fn@googlegroups.com>
Subject: Re: Need some SQL
From: ron81...@gmail.com (Ron Paii)
Injection-Date: Thu, 12 Aug 2021 17:37:10 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Ron Paii - Thu, 12 Aug 2021 17:37 UTC

On Thursday, August 12, 2021 at 10:20:06 AM UTC-5, Keith Tizzard wrote:
> Ron, that selects Reg dates between start and end. I need the anniversary dates to be in the date range. The reg dates will be a number of years earlier
> On Thursday, 12 August 2021 at 16:13:32 UTC+1, Ron Paii wrote:
> > On Thursday, August 12, 2021 at 10:11:37 AM UTC-5, Ron Paii wrote:
> > > On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
> > > > I have a table of vehicle registration dates with the relevant fields:
> > > > VehicleID, RegDate
> > > >
> > > > Work needs to be carried out on a vehicle on the anniversary of its RegDate.
> > > >
> > > > I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.
> > > >
> > > > I may end up with:
> > > > 223, 12/11/2008
> > > > 334, 13/11/2013
> > > > 345, 13/11/2020
> > > > 444, 14/11/2017
> > > > ...
> > > > 393, 05/01/2009
> > > > 998, 07/01/2003
> > > >
> > > > Is there a simple SQL to achieve this?
> > > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > > SELECT tblReg.ID, tblReg.RegDate
> > > FROM tblReg
> > > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);
> > Add DateValue to end date
> > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > SELECT tblReg.ID, tblReg.RegDate
> > FROM tblReg
> > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,DateValue([DateEnd]));

DateStart and DateEnd are date parameters. You would supply say #12/11/2008# and #13/11/2017# when the query is run. Using typed parameters allows for almost any date format and error if no date is entered. If you want a fixed range, delete the parameters and enter the dates.

Re: Need some SQL

<60d6b551-d41f-49a6-9931-47ed4ec188c1n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:622a:344:: with SMTP id r4mr4870426qtw.296.1628790524962;
Thu, 12 Aug 2021 10:48:44 -0700 (PDT)
X-Received: by 2002:a05:6830:1c34:: with SMTP id f20mr4496650ote.283.1628790523202;
Thu, 12 Aug 2021 10:48:43 -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, 12 Aug 2021 10:48:43 -0700 (PDT)
In-Reply-To: <d546d523-80a5-44f4-b0b0-1aed4463379fn@googlegroups.com>
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>
<d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com> <0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
<682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com> <d546d523-80a5-44f4-b0b0-1aed4463379fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <60d6b551-d41f-49a6-9931-47ed4ec188c1n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Thu, 12 Aug 2021 17:48:44 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Keith Tizzard - Thu, 12 Aug 2021 17:48 UTC

I have no problem with DateStart and DateEnd nor with parameters. You are selecting on the RegDate being within that range. I need the Anniversary of the RegDate

In your example I would want to be able to select a RegDate of 12/12/2001 because its anniversary falls on 12/12/2008 and again on 12/12/2009 etc

On Thursday, 12 August 2021 at 18:37:12 UTC+1, Ron Paii wrote:
> On Thursday, August 12, 2021 at 10:20:06 AM UTC-5, Keith Tizzard wrote:
> > Ron, that selects Reg dates between start and end. I need the anniversary dates to be in the date range. The reg dates will be a number of years earlier
> > On Thursday, 12 August 2021 at 16:13:32 UTC+1, Ron Paii wrote:
> > > On Thursday, August 12, 2021 at 10:11:37 AM UTC-5, Ron Paii wrote:
> > > > On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
> > > > > I have a table of vehicle registration dates with the relevant fields:
> > > > > VehicleID, RegDate
> > > > >
> > > > > Work needs to be carried out on a vehicle on the anniversary of its RegDate.
> > > > >
> > > > > I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.

In your example I would want to include a RegDate of
> > > > >
> > > > > I may end up with:
> > > > > 223, 12/11/2008
> > > > > 334, 13/11/2013
> > > > > 345, 13/11/2020
> > > > > 444, 14/11/2017
> > > > > ...
> > > > > 393, 05/01/2009
> > > > > 998, 07/01/2003
> > > > >
> > > > > Is there a simple SQL to achieve this?
> > > > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > > > SELECT tblReg.ID, tblReg.RegDate
> > > > FROM tblReg
> > > > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);
> > > Add DateValue to end date
> > > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > > SELECT tblReg.ID, tblReg.RegDate
> > > FROM tblReg
> > > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,DateValue([DateEnd]));
> DateStart and DateEnd are date parameters. You would supply say #12/11/2008# and #13/11/2017# when the query is run. Using typed parameters allows for almost any date format and error if no date is entered. If you want a fixed range, delete the parameters and enter the dates.

Re: Need some SQL

<7660f4c2-5126-415c-8055-ed4552b78129n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a37:8242:: with SMTP id e63mr6074157qkd.294.1628794531665;
Thu, 12 Aug 2021 11:55:31 -0700 (PDT)
X-Received: by 2002:a05:6808:f8e:: with SMTP id o14mr4375129oiw.34.1628794531407;
Thu, 12 Aug 2021 11:55:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.niel.me!usenet.pasdenom.info!usenet-fr.net!fdn.fr!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, 12 Aug 2021 11:55:31 -0700 (PDT)
In-Reply-To: <60d6b551-d41f-49a6-9931-47ed4ec188c1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=65.30.79.18; posting-account=RurhpQoAAACBjKrwaxvElRMdPO3AZiPP
NNTP-Posting-Host: 65.30.79.18
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com> <0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
<682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com> <d546d523-80a5-44f4-b0b0-1aed4463379fn@googlegroups.com>
<60d6b551-d41f-49a6-9931-47ed4ec188c1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7660f4c2-5126-415c-8055-ed4552b78129n@googlegroups.com>
Subject: Re: Need some SQL
From: ron81...@gmail.com (Ron Paii)
Injection-Date: Thu, 12 Aug 2021 18:55:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Ron Paii - Thu, 12 Aug 2021 18:55 UTC

On Thursday, August 12, 2021 at 12:48:47 PM UTC-5, Keith Tizzard wrote:
> I have no problem with DateStart and DateEnd nor with parameters. You are selecting on the RegDate being within that range. I need the Anniversary of the RegDate
>
> In your example I would want to be able to select a RegDate of 12/12/2001 because its anniversary falls on 12/12/2008 and again on 12/12/2009 etc
> On Thursday, 12 August 2021 at 18:37:12 UTC+1, Ron Paii wrote:
> > On Thursday, August 12, 2021 at 10:20:06 AM UTC-5, Keith Tizzard wrote:
> > > Ron, that selects Reg dates between start and end. I need the anniversary dates to be in the date range. The reg dates will be a number of years earlier
> > > On Thursday, 12 August 2021 at 16:13:32 UTC+1, Ron Paii wrote:
> > > > On Thursday, August 12, 2021 at 10:11:37 AM UTC-5, Ron Paii wrote:
> > > > > On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
> > > > > > I have a table of vehicle registration dates with the relevant fields:
> > > > > > VehicleID, RegDate
> > > > > >
> > > > > > Work needs to be carried out on a vehicle on the anniversary of its RegDate.
> > > > > >
> > > > > > I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.
> In your example I would want to include a RegDate of
> > > > > >
> > > > > > I may end up with:
> > > > > > 223, 12/11/2008
> > > > > > 334, 13/11/2013
> > > > > > 345, 13/11/2020
> > > > > > 444, 14/11/2017
> > > > > > ...
> > > > > > 393, 05/01/2009
> > > > > > 998, 07/01/2003
> > > > > >
> > > > > > Is there a simple SQL to achieve this?
> > > > > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > > > > SELECT tblReg.ID, tblReg.RegDate
> > > > > FROM tblReg
> > > > > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);
> > > > Add DateValue to end date
> > > > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > > > SELECT tblReg.ID, tblReg.RegDate
> > > > FROM tblReg
> > > > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,DateValue([DateEnd]));
> > DateStart and DateEnd are date parameters. You would supply say #12/11/2008# and #13/11/2017# when the query is run. Using typed parameters allows for almost any date format and error if no date is entered. If you want a fixed range, delete the parameters and enter the dates.

Now I understand, you are only looking a the month and day of the date range.
Try the following, Excluded null dates to prevent error in Month and Day functions.

PARAMETERS DateStart DateTime, DateEnd DateTime;
SELECT tblReg.ID, tblReg.RegDate
FROM tblReg
WHERE tblReg.RegDateIs Not Null AND DateSerial(Year(Now()),Month([RegDate]),Day([RegDate])) Between DateSerial(Year(Now()),Month([DateStart]),Day([DateStart])) And DateSerial(Year(Now()),Month([DateEnd]),Day([DateEnd]));

Re: Need some SQL

<ba658f5c-f9fb-4ea3-95b5-b6ecb8545949n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:ad4:5bc7:: with SMTP id t7mr6063784qvt.10.1628802312020;
Thu, 12 Aug 2021 14:05:12 -0700 (PDT)
X-Received: by 2002:a05:6830:1c34:: with SMTP id f20mr5136221ote.283.1628802311775;
Thu, 12 Aug 2021 14:05:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.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.databases.ms-access
Date: Thu, 12 Aug 2021 14:05:11 -0700 (PDT)
In-Reply-To: <7660f4c2-5126-415c-8055-ed4552b78129n@googlegroups.com>
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>
<d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com> <0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
<682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com> <d546d523-80a5-44f4-b0b0-1aed4463379fn@googlegroups.com>
<60d6b551-d41f-49a6-9931-47ed4ec188c1n@googlegroups.com> <7660f4c2-5126-415c-8055-ed4552b78129n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba658f5c-f9fb-4ea3-95b5-b6ecb8545949n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Thu, 12 Aug 2021 21:05:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5300
 by: Keith Tizzard - Thu, 12 Aug 2021 21:05 UTC

Ron

Thanks for your continued interest in this.

That's interesting and it works if the DateStart and DateEnd are in the same year. However let's take DateStart as 1/11/20 and DateEnd as 31/1/21. I'm looking for registration anniversaries in November, December and January..

Your condition becomes Between 1/11/21 and 31/1/21. or simply between 31/1/21 and 1/11/21. This picks up the very months I wouldn't want.

Now do you see the problem?

On Thursday, 12 August 2021 at 19:55:34 UTC+1, Ron Paii wrote:
> On Thursday, August 12, 2021 at 12:48:47 PM UTC-5, Keith Tizzard wrote:
> > I have no problem with DateStart and DateEnd nor with parameters. You are selecting on the RegDate being within that range. I need the Anniversary of the RegDate
> >
> > In your example I would want to be able to select a RegDate of 12/12/2001 because its anniversary falls on 12/12/2008 and again on 12/12/2009 etc
> > On Thursday, 12 August 2021 at 18:37:12 UTC+1, Ron Paii wrote:
> > > On Thursday, August 12, 2021 at 10:20:06 AM UTC-5, Keith Tizzard wrote:
> > > > Ron, that selects Reg dates between start and end. I need the anniversary dates to be in the date range. The reg dates will be a number of years earlier
> > > > On Thursday, 12 August 2021 at 16:13:32 UTC+1, Ron Paii wrote:
> > > > > On Thursday, August 12, 2021 at 10:11:37 AM UTC-5, Ron Paii wrote:
> > > > > > On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
> > > > > > > I have a table of vehicle registration dates with the relevant fields:
> > > > > > > VehicleID, RegDate
> > > > > > >
> > > > > > > Work needs to be carried out on a vehicle on the anniversary of its RegDate.
> > > > > > >
> > > > > > > I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year..
> > In your example I would want to include a RegDate of
> > > > > > >
> > > > > > > I may end up with:
> > > > > > > 223, 12/11/2008
> > > > > > > 334, 13/11/2013
> > > > > > > 345, 13/11/2020
> > > > > > > 444, 14/11/2017
> > > > > > > ...
> > > > > > > 393, 05/01/2009
> > > > > > > 998, 07/01/2003
> > > > > > >
> > > > > > > Is there a simple SQL to achieve this?
> > > > > > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > > > > > SELECT tblReg.ID, tblReg.RegDate
> > > > > > FROM tblReg
> > > > > > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);
> > > > > Add DateValue to end date
> > > > > PARAMETERS DateStart DateTime, DateEnd DateTime;
> > > > > SELECT tblReg.ID, tblReg.RegDate
> > > > > FROM tblReg
> > > > > WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,DateValue([DateEnd]));
> > > DateStart and DateEnd are date parameters. You would supply say #12/11/2008# and #13/11/2017# when the query is run. Using typed parameters allows for almost any date format and error if no date is entered. If you want a fixed range, delete the parameters and enter the dates.
> Now I understand, you are only looking a the month and day of the date range.
> Try the following, Excluded null dates to prevent error in Month and Day functions.
> PARAMETERS DateStart DateTime, DateEnd DateTime;
> SELECT tblReg.ID, tblReg.RegDate
> FROM tblReg
> WHERE tblReg.RegDateIs Not Null AND DateSerial(Year(Now()),Month([RegDate]),Day([RegDate])) Between DateSerial(Year(Now()),Month([DateStart]),Day([DateStart])) And DateSerial(Year(Now()),Month([DateEnd]),Day([DateEnd]));

Re: Need some SQL

<sf63qn$clf$1@dont-email.me>

  copy mid

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

  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: Fri, 13 Aug 2021 11:41:12 -0400
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <sf63qn$clf$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
<d7d336fc-2896-4adb-98b1-a6cf046b9d68n@googlegroups.com>
<0f512dc1-5c52-4668-a52b-d00a88447473n@googlegroups.com>
<682cae83-025f-4e70-b9bb-5b0de0585b75n@googlegroups.com>
<d546d523-80a5-44f4-b0b0-1aed4463379fn@googlegroups.com>
<60d6b551-d41f-49a6-9931-47ed4ec188c1n@googlegroups.com>
<7660f4c2-5126-415c-8055-ed4552b78129n@googlegroups.com>
<ba658f5c-f9fb-4ea3-95b5-b6ecb8545949n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Aug 2021 15:41:11 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9a7f88091c50d58593b8c3d3d7ff1a63";
logging-data="12975"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18m6SYqIwgsi8rSxEeQxjNDqdWyAA+HJRc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:GmrRXPAjBrAe0sSbY5abc3NSdQA=
In-Reply-To: <ba658f5c-f9fb-4ea3-95b5-b6ecb8545949n@googlegroups.com>
Content-Language: en-US
 by: Neil - Fri, 13 Aug 2021 15:41 UTC

On 8/12/2021 5:05 PM, Keith Tizzard wrote:
> Ron
>
> Thanks for your continued interest in this.
>
> That's interesting and it works if the DateStart and DateEnd are in the same year. However let's take DateStart as 1/11/20 and DateEnd as 31/1/21. I'm looking for registration anniversaries in November, December and January.
>
> Your condition becomes Between 1/11/21 and 31/1/21. or simply between 31/1/21 and 1/11/21. This picks up the very months I wouldn't want.
>
> Now do you see the problem?
>
I see more than one problem trying to be solved in a simple manner! ;-)

However, Ron's code may be easily modifiable to address the year issue.
His code uses Year(Now()) in both parts of the query, which results in
all of the selections to fall in the same year.

Simply put in the year discretely, as in
FROM (Year(2020)) TO (Year(2021))

Of course, this can't be done if the dates aren't entered manually. In
that case, you'd need multiple queries, and select the one that fits
your needs.

Neil

> On Thursday, 12 August 2021 at 19:55:34 UTC+1, Ron Paii wrote:
>> On Thursday, August 12, 2021 at 12:48:47 PM UTC-5, Keith Tizzard wrote:
>>> I have no problem with DateStart and DateEnd nor with parameters. You are selecting on the RegDate being within that range. I need the Anniversary of the RegDate
>>>
>>> In your example I would want to be able to select a RegDate of 12/12/2001 because its anniversary falls on 12/12/2008 and again on 12/12/2009 etc
>>> On Thursday, 12 August 2021 at 18:37:12 UTC+1, Ron Paii wrote:
>>>> On Thursday, August 12, 2021 at 10:20:06 AM UTC-5, Keith Tizzard wrote:
>>>>> Ron, that selects Reg dates between start and end. I need the anniversary dates to be in the date range. The reg dates will be a number of years earlier
>>>>> On Thursday, 12 August 2021 at 16:13:32 UTC+1, Ron Paii wrote:
>>>>>> On Thursday, August 12, 2021 at 10:11:37 AM UTC-5, Ron Paii wrote:
>>>>>>> On Thursday, August 12, 2021 at 6:27:25 AM UTC-5, Keith Tizzard wrote:
>>>>>>>> I have a table of vehicle registration dates with the relevant fields:
>>>>>>>> VehicleID, RegDate
>>>>>>>>
>>>>>>>> Work needs to be carried out on a vehicle on the anniversary of its RegDate.
>>>>>>>>
>>>>>>>> I need to find all the vehicles whose anniversary falls between two given dates. The date range may start in one year (say in November) and end in the next (say in February), or it may be solely in a single year.
>>> In your example I would want to include a RegDate of
>>>>>>>>
>>>>>>>> I may end up with:
>>>>>>>> 223, 12/11/2008
>>>>>>>> 334, 13/11/2013
>>>>>>>> 345, 13/11/2020
>>>>>>>> 444, 14/11/2017
>>>>>>>> ...
>>>>>>>> 393, 05/01/2009
>>>>>>>> 998, 07/01/2003
>>>>>>>>
>>>>>>>> Is there a simple SQL to achieve this?
>>>>>>> PARAMETERS DateStart DateTime, DateEnd DateTime;
>>>>>>> SELECT tblReg.ID, tblReg.RegDate
>>>>>>> FROM tblReg
>>>>>>> WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,[DateEnd]);
>>>>>> Add DateValue to end date
>>>>>> PARAMETERS DateStart DateTime, DateEnd DateTime;
>>>>>> SELECT tblReg.ID, tblReg.RegDate
>>>>>> FROM tblReg
>>>>>> WHERE tblReg.RegDate>=[DateStart] And tblReg.RegDate<DateAdd("d",1,DateValue([DateEnd]));
>>>> DateStart and DateEnd are date parameters. You would supply say #12/11/2008# and #13/11/2017# when the query is run. Using typed parameters allows for almost any date format and error if no date is entered. If you want a fixed range, delete the parameters and enter the dates.
>> Now I understand, you are only looking a the month and day of the date range.
>> Try the following, Excluded null dates to prevent error in Month and Day functions.
>> PARAMETERS DateStart DateTime, DateEnd DateTime;
>> SELECT tblReg.ID, tblReg.RegDate
>> FROM tblReg
>> WHERE tblReg.RegDateIs Not Null AND DateSerial(Year(Now()),Month([RegDate]),Day([RegDate])) Between DateSerial(Year(Now()),Month([DateStart]),Day([DateStart])) And DateSerial(Year(Now()),Month([DateEnd]),Day([DateEnd]));

--
best regards,

Neil

Re: Need some SQL

<sf67th$avh$1@dont-email.me>

  copy mid

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

  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: Fri, 13 Aug 2021 12:50:56 -0400
Organization: WorksRite
Lines: 38
Message-ID: <sf67th$avh$1@dont-email.me>
References: <f1f90ec7-f445-4424-a826-32533bfd549cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Aug 2021 16:50:57 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="80020eed0a2029ec4d32a3bdb007d2da";
logging-data="11249"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nhnS2daAATR6NKSBqYobx"
Cancel-Lock: sha1:qdxSdcN4ZZNc19HbQMe5kHOxjHs=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210813-0, 8/12/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Fri, 13 Aug 2021 16:50 UTC

Keith Tizzard has brought this to us :
> I have a table of vehicle registration dates with the relevant fields:
> VehicleID, RegDate
>
> Work needs to be carried out on a vehicle on the anniversary of its RegDate.
>
> I need to find all the vehicles whose anniversary falls between two given
> dates. The date range may start in one year (say in November) and end in the
> next (say in February), or it may be solely in a single year.
>
> I may end up with:
> 223, 12/11/2008
> 334, 13/11/2013
> 345, 13/11/2020
> 444, 14/11/2017
> ...
> 393, 05/01/2009
> 998, 07/01/2003
>
> Is there a simple SQL to achieve this?

I am a little late to this party, and I probably don't understand what
you are trying to do, but why not use the "Between" operator.

Select Whatever From SomeTable
Where SomeColumn between [StartDate] and [EndDate]

Access insists that # delimits dates.

So if I were building a string with the sql statement it would go
something like this:

strSql = "Select Whatever From SomeTable Where SomeColumn between #"
strSql = strSql & [StartDate] & "# and #" & [EndDate] & "#"

Hope this helps

Rdub

Re: Need some SQL

<1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a0c:fe02:: with SMTP id x2mr495634qvr.12.1628937637672;
Sat, 14 Aug 2021 03:40:37 -0700 (PDT)
X-Received: by 2002:a05:6808:147:: with SMTP id h7mr5100690oie.14.1628937637426;
Sat, 14 Aug 2021 03:40:37 -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: Sat, 14 Aug 2021 03:40:37 -0700 (PDT)
In-Reply-To: <sf67th$avh$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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1c831d15-4773-4c80-a77f-71cf829181d8n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Sat, 14 Aug 2021 10:40:37 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Keith Tizzard - Sat, 14 Aug 2021 10:40 UTC

Ron, I agree that I need
Select Whatever From SomeTable
Where SomeColumn between [StartDate] and [EndDate]

The problem in the SomeColumn. I have the registration dates of vehicles. I need to find those vehicles whose Anniversary of their Registration dates falls within the date range - not the Registration dates themselves.

On Friday, 13 August 2021 at 17:51:02 UTC+1, Ron Weiner wrote:
> Keith Tizzard has brought this to us :
> > I have a table of vehicle registration dates with the relevant fields:
> > VehicleID, RegDate
> >
> > Work needs to be carried out on a vehicle on the anniversary of its RegDate.
> >
> > I need to find all the vehicles whose anniversary falls between two given
> > dates. The date range may start in one year (say in November) and end in the
> > next (say in February), or it may be solely in a single year.
> >
> > I may end up with:
> > 223, 12/11/2008
> > 334, 13/11/2013
> > 345, 13/11/2020
> > 444, 14/11/2017
> > ...
> > 393, 05/01/2009
> > 998, 07/01/2003
> >
> > Is there a simple SQL to achieve this?
> I am a little late to this party, and I probably don't understand what
> you are trying to do, but why not use the "Between" operator.
>
> Select Whatever From SomeTable
> Where SomeColumn between [StartDate] and [EndDate]
>
> Access insists that # delimits dates.
>
> So if I were building a string with the sql statement it would go
> something like this:
>
> strSql = "Select Whatever From SomeTable Where SomeColumn between #"
> strSql = strSql & [StartDate] & "# and #" & [EndDate] & "#"
>
> Hope this helps
>
> Rdub

Re: Need some SQL

<sf8kdt$hu$1@dont-email.me>

  copy mid

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

  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: Sat, 14 Aug 2021 10:36:41 -0400
Organization: WorksRite
Lines: 70
Message-ID: <sf8kdt$hu$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>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 14 Aug 2021 14:36:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="376fcc66d9c8f75ab3f802ff548005f7";
logging-data="574"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2ZgPfHsPVdT640pgzalQ6"
Cancel-Lock: sha1:Do6ghJ7a5dBoE2Bgep1F7R7gfbs=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210814-0, 8/13/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Sat, 14 Aug 2021 14:36 UTC

Keith Tizzard has brought this to us :
> Ron, I agree that I need
> Select Whatever From SomeTable
> Where SomeColumn between [StartDate] and [EndDate]
>
> The problem in the SomeColumn. I have the registration dates of vehicles. I
> need to find those vehicles whose Anniversary of their Registration dates
> falls within the date range - not the Registration dates themselves.
>
OK, think I got it... Need to do a little date math to move the
registration dates into the current year. I believe this has a chance
of working. I am assuming a column RegDate in your SomeTable:

Select Stuff From SomeTable
Where
CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
Between #[StartDate]# And #[EndDate]#

What I am (attempting) doing here is to calculate the number of years
from the registration date to today, and then Add that number of years
into the registration date before comparing in the Between statement.

This is untested! Let me know if I am getting closer.

Rdub

>
> On Friday, 13 August 2021 at 17:51:02 UTC+1, Ron Weiner wrote:
>> Keith Tizzard has brought this to us :
>>> I have a table of vehicle registration dates with the relevant fields:
>>> VehicleID, RegDate
>>>
>>> Work needs to be carried out on a vehicle on the anniversary of its
>>> RegDate.
>>>
>>> I need to find all the vehicles whose anniversary falls between two given
>>> dates. The date range may start in one year (say in November) and end in
>>> the next (say in February), or it may be solely in a single year.
>>>
>>> I may end up with:
>>> 223, 12/11/2008
>>> 334, 13/11/2013
>>> 345, 13/11/2020
>>> 444, 14/11/2017
>>> ...
>>> 393, 05/01/2009
>>> 998, 07/01/2003
>>>
>>> Is there a simple SQL to achieve this?
>> I am a little late to this party, and I probably don't understand what
>> you are trying to do, but why not use the "Between" operator.
>>
>> Select Whatever From SomeTable
>> Where SomeColumn between [StartDate] and [EndDate]
>>
>> Access insists that # delimits dates.
>>
>> So if I were building a string with the sql statement it would go
>> something like this:
>>
>> strSql = "Select Whatever From SomeTable Where SomeColumn between #"
>> strSql = strSql & [StartDate] & "# and #" & [EndDate] & "#"
>>
>> Hope this helps
>>
>> Rdub

Re: Need some SQL

<be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:ac8:57c4:: with SMTP id w4mr6656161qta.39.1628957855320;
Sat, 14 Aug 2021 09:17:35 -0700 (PDT)
X-Received: by 2002:a05:6808:14cf:: with SMTP id f15mr6199889oiw.145.1628957855084;
Sat, 14 Aug 2021 09:17:35 -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: Sat, 14 Aug 2021 09:17:34 -0700 (PDT)
In-Reply-To: <sf8kdt$hu$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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <be4a7218-187c-450e-94a8-043e33c45e70n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Sat, 14 Aug 2021 16:17:35 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Keith Tizzard - Sat, 14 Aug 2021 16:17 UTC

Ron, thanks for your interest.

I have had a similar exchange with your namesake earlier in this discussion

The problem occurs when the StartDate and EndDate are in different years. (we can assume for simplicity that these would be consecutive years)

On Saturday, 14 August 2021 at 15:36:49 UTC+1, Ron Weiner wrote:
> Keith Tizzard has brought this to us :
> > Ron, I agree that I need
> > Select Whatever From SomeTable
> > Where SomeColumn between [StartDate] and [EndDate]
> >
> > The problem in the SomeColumn. I have the registration dates of vehicles. I
> > need to find those vehicles whose Anniversary of their Registration dates
> > falls within the date range - not the Registration dates themselves.
> >
> OK, think I got it... Need to do a little date math to move the
> registration dates into the current year. I believe this has a chance
> of working. I am assuming a column RegDate in your SomeTable:
>
> Select Stuff From SomeTable
> Where
> CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
> Between #[StartDate]# And #[EndDate]#
>
>
> What I am (attempting) doing here is to calculate the number of years
> from the registration date to today, and then Add that number of years
> into the registration date before comparing in the Between statement.
>
> This is untested! Let me know if I am getting closer.
>
> Rdub
> >
> > On Friday, 13 August 2021 at 17:51:02 UTC+1, Ron Weiner wrote:
> >> Keith Tizzard has brought this to us :
> >>> I have a table of vehicle registration dates with the relevant fields:
> >>> VehicleID, RegDate
> >>>
> >>> Work needs to be carried out on a vehicle on the anniversary of its
> >>> RegDate.
> >>>
> >>> I need to find all the vehicles whose anniversary falls between two given
> >>> dates. The date range may start in one year (say in November) and end in
> >>> the next (say in February), or it may be solely in a single year.
> >>>
> >>> I may end up with:
> >>> 223, 12/11/2008
> >>> 334, 13/11/2013
> >>> 345, 13/11/2020
> >>> 444, 14/11/2017
> >>> ...
> >>> 393, 05/01/2009
> >>> 998, 07/01/2003
> >>>
> >>> Is there a simple SQL to achieve this?
> >> I am a little late to this party, and I probably don't understand what
> >> you are trying to do, but why not use the "Between" operator.
> >>
> >> Select Whatever From SomeTable
> >> Where SomeColumn between [StartDate] and [EndDate]
> >>
> >> Access insists that # delimits dates.
> >>
> >> So if I were building a string with the sql statement it would go
> >> something like this:
> >>
> >> strSql = "Select Whatever From SomeTable Where SomeColumn between #"
> >> strSql = strSql & [StartDate] & "# and #" & [EndDate] & "#"
> >>
> >> Hope this helps
> >>
> >> Rdub

Re: Need some SQL

<sf8r00$tpb$1@dont-email.me>

  copy mid

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

  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: Sat, 14 Aug 2021 12:28:46 -0400
Organization: WorksRite
Lines: 76
Message-ID: <sf8r00$tpb$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>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 14 Aug 2021 16:28:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="376fcc66d9c8f75ab3f802ff548005f7";
logging-data="30507"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yMKTNhBsZWEvZbVI5ulMd"
Cancel-Lock: sha1:4FbIlWcKCHok55blDLIfLvOQKqg=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210814-0, 8/13/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Sat, 14 Aug 2021 16:28 UTC

Keith Tizzard explained on 8/14/2021 :
> Ron, thanks for your interest.
>
> I have had a similar exchange with your namesake earlier in this discussion
>
> The problem occurs when the StartDate and EndDate are in different years. (we
> can assume for simplicity that these would be consecutive years)
>
>
> On Saturday, 14 August 2021 at 15:36:49 UTC+1, Ron Weiner wrote:
>> Keith Tizzard has brought this to us :
>>> Ron, I agree that I need
>>> Select Whatever From SomeTable
>>> Where SomeColumn between [StartDate] and [EndDate]
>>>
>>> The problem in the SomeColumn. I have the registration dates of vehicles. I
>>> need to find those vehicles whose Anniversary of their Registration dates
>>> falls within the date range - not the Registration dates themselves.
>>>
>> OK, think I got it... Need to do a little date math to move the
>> registration dates into the current year. I believe this has a chance
>> of working. I am assuming a column RegDate in your SomeTable:
>>
>> Select Stuff From SomeTable
>> Where
>> CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
>> Between #[StartDate]# And #[EndDate]#
>>
>>
>> What I am (attempting) doing here is to calculate the number of years
>> from the registration date to today, and then Add that number of years
>> into the registration date before comparing in the Between statement.
>>
>> This is untested! Let me know if I am getting closer.
>>
>> Rdub
>>>
>>> On Friday, 13 August 2021 at 17:51:02 UTC+1, Ron Weiner wrote:
>>>> Keith Tizzard has brought this to us :
>>>>> I have a table of vehicle registration dates with the relevant fields:
>>>>> VehicleID, RegDate
>>>>>
>>>>> Work needs to be carried out on a vehicle on the anniversary of its
>>>>> RegDate.
>>>>>
>>>>> I need to find all the vehicles whose anniversary falls between two given
>>>>> dates. The date range may start in one year (say in November) and end in
>>>>> the next (say in February), or it may be solely in a single year.
>>>>>
>>>>> I may end up with:
>>>>> 223, 12/11/2008
>>>>> 334, 13/11/2013
>>>>> 345, 13/11/2020
>>>>> 444, 14/11/2017
>>>>> ...
>>>>> 393, 05/01/2009
>>>>> 998, 07/01/2003
>>>>>
>>>>> Is there a simple SQL to achieve this?
>>>> I am a little late to this party, and I probably don't understand what
>>>> you are trying to do, but why not use the "Between" operator.
>>>>
>>>> Select Whatever From SomeTable
>>>> Where SomeColumn between [StartDate] and [EndDate]
>>>>
>>>> Access insists that # delimits dates.
>>>>
>>>> So if I were building a string with the sql statement it would go
>>>> something like this:
>>>>
>>>> strSql = "Select Whatever From SomeTable Where SomeColumn between #"
>>>> strSql = strSql & [StartDate] & "# and #" & [EndDate] & "#"
>>>>
>>>> Hope this helps
>>>>
>>>> Rdub

Re: Need some SQL

<sf8r5q$1ul$1@dont-email.me>

  copy mid

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

  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: Sat, 14 Aug 2021 12:31:52 -0400
Organization: WorksRite
Lines: 84
Message-ID: <sf8r5q$1ul$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>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 14 Aug 2021 16:31:54 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="376fcc66d9c8f75ab3f802ff548005f7";
logging-data="2005"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tXfXl+qNMd+35I9V3/cXX"
Cancel-Lock: sha1:a75k/e74HIdfHsIPF6A08VulbYI=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210814-0, 8/13/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Sat, 14 Aug 2021 16:31 UTC

Keith Tizzard explained on 8/14/2021 :
OOOps got a little to wonky on the Send button.

AnywayI am probably not understanding your requirement. Can you supply
a small sampling of data and your criteria for selecting records, that
innustrate the issue you are having.

Rdub

> Ron, thanks for your interest.
>
> I have had a similar exchange with your namesake earlier in this discussion
>
> The problem occurs when the StartDate and EndDate are in different years. (we
> can assume for simplicity that these would be consecutive years)
>
>
> On Saturday, 14 August 2021 at 15:36:49 UTC+1, Ron Weiner wrote:
>> Keith Tizzard has brought this to us :
>>> Ron, I agree that I need
>>> Select Whatever From SomeTable
>>> Where SomeColumn between [StartDate] and [EndDate]
>>>
>>> The problem in the SomeColumn. I have the registration dates of vehicles. I
>>> need to find those vehicles whose Anniversary of their Registration dates
>>> falls within the date range - not the Registration dates themselves.
>>>
>> OK, think I got it... Need to do a little date math to move the
>> registration dates into the current year. I believe this has a chance
>> of working. I am assuming a column RegDate in your SomeTable:
>>
>> Select Stuff From SomeTable
>> Where
>> CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
>> Between #[StartDate]# And #[EndDate]#
>>
>>
>> What I am (attempting) doing here is to calculate the number of years
>> from the registration date to today, and then Add that number of years
>> into the registration date before comparing in the Between statement.
>>
>> This is untested! Let me know if I am getting closer.
>>
>> Rdub
>>>
>>> On Friday, 13 August 2021 at 17:51:02 UTC+1, Ron Weiner wrote:
>>>> Keith Tizzard has brought this to us :
>>>>> I have a table of vehicle registration dates with the relevant fields:
>>>>> VehicleID, RegDate
>>>>>
>>>>> Work needs to be carried out on a vehicle on the anniversary of its
>>>>> RegDate.
>>>>>
>>>>> I need to find all the vehicles whose anniversary falls between two given
>>>>> dates. The date range may start in one year (say in November) and end in
>>>>> the next (say in February), or it may be solely in a single year.
>>>>>
>>>>> I may end up with:
>>>>> 223, 12/11/2008
>>>>> 334, 13/11/2013
>>>>> 345, 13/11/2020
>>>>> 444, 14/11/2017
>>>>> ...
>>>>> 393, 05/01/2009
>>>>> 998, 07/01/2003
>>>>>
>>>>> Is there a simple SQL to achieve this?
>>>> I am a little late to this party, and I probably don't understand what
>>>> you are trying to do, but why not use the "Between" operator.
>>>>
>>>> Select Whatever From SomeTable
>>>> Where SomeColumn between [StartDate] and [EndDate]
>>>>
>>>> Access insists that # delimits dates.
>>>>
>>>> So if I were building a string with the sql statement it would go
>>>> something like this:
>>>>
>>>> strSql = "Select Whatever From SomeTable Where SomeColumn between #"
>>>> strSql = strSql & [StartDate] & "# and #" & [EndDate] & "#"
>>>>
>>>> Hope this helps
>>>>
>>>> Rdub

Re: Need some SQL

<XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>

  copy mid

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

  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: Sat, 14 Aug 2021 22:09:25 -0000 (UTC)
Message-ID: <XnsAD8719D7DAADammammatatiscalineti@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>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 14 Aug 2021 22:09:25 -0000 (UTC)
Injection-Info: solani.org;
logging-data="23198"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Xnews/??.01.30 Mime-proxy/2.3.c.1 (Win32)
Cancel-Lock: sha1:rTfOKVXK+S8woo6i+wO9FuuYhjw=
X-User-ID: eJwNyckBwDAIA7CVcMMRxsEU9h+h1Vd2HN6hbq62th5+oSss75k4826K9LVQBE9PkXMVmeRbu4i/kUXRB0R/YQQV5g==
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[:
 by: Ammammata - Sat, 14 Aug 2021 22:09 UTC

Il giorno Sat 14 Aug 2021 06:31:52p, *Ron Weiner* ha inviato su
comp.databases.ms-access il messaggio news:sf8r5q$1ul$1@dont-email.me.
Vediamo cosa ha scritto:

> AnywayI am probably not understanding your requirement.

he has been quite clear in his request

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

Re: Need some SQL

<8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:a05:622a:14ce:: with SMTP id u14mr9163658qtx.165.1629023444527;
Sun, 15 Aug 2021 03:30:44 -0700 (PDT)
X-Received: by 2002:aca:d06:: with SMTP id 6mr2835801oin.105.1629023444157;
Sun, 15 Aug 2021 03:30:44 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!feeder1.cambriumusenet.nl!feed.tweak.nl!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 03:30:43 -0700 (PDT)
In-Reply-To: <XnsAD8719D7DAADammammatatiscalineti@127.0.0.1>
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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
Subject: Re: Need some SQL
From: internet...@foobox.com (Keith Tizzard)
Injection-Date: Sun, 15 Aug 2021 10:30:44 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2325
 by: Keith Tizzard - Sun, 15 Aug 2021 10:30 UTC

Ron

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

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

This should produce vehicles
235
332
321
665
215

Within this the anniversary of 235 is 8/11/2020
and the anniversary of 215 is 12/1/2021

Hope this explains the issue

On Saturday, 14 August 2021 at 23:09:30 UTC+1, Ammammata wrote:
> Il giorno Sat 14 Aug 2021 06:31:52p, *Ron Weiner* ha inviato su
> comp.databases.ms-access il messaggio news:sf8r5q$1ul$1...@dont-email.me.
> Vediamo cosa ha scritto:
> > AnywayI am probably not understanding your requirement.
> he has been quite clear in his request
> --
> /-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
> -=- -=- -=- -=- -=- -=- -=- -=- - -=-
> ........... [ al lavoro ] ...........

Re: Need some SQL

<55cc3a96-ec5b-4f65-9db5-aa1711f814d8n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.databases.ms-access
X-Received: by 2002:ac8:518a:: with SMTP id c10mr2087qtn.247.1629028467329; Sun, 15 Aug 2021 04:54:27 -0700 (PDT)
X-Received: by 2002:a4a:ce81:: with SMTP id f1mr8113862oos.58.1629028466984; Sun, 15 Aug 2021 04:54:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!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 04:54:26 -0700 (PDT)
In-Reply-To: <8037f4fc-dfdb-4d7d-8858-371740811704n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=175.32.164.198; posting-account=-KkQ3goAAAC0EmTjPzZ3SpbutZqEGtGB
NNTP-Posting-Host: 175.32.164.198
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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <55cc3a96-ec5b-4f65-9db5-aa1711f814d8n@googlegroups.com>
Subject: Re: Need some SQL
From: mal.re...@gmail.com (mal....@gmail.com)
Injection-Date: Sun, 15 Aug 2021 11:54:27 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 55
 by: mal....@gmail.com - Sun, 15 Aug 2021 11:54 UTC

I'm not on a machine with Access, so can't test any SQL, but I think an answer might come from using "Mod 12" in your date calculations.
For instance - to grab the month (eg 11 for NOV.....add 3 (if the date range was 3 months (DateDiff), and then "mod 12" it.
That will wrap around the year whenever it adds to more than 12
11 + 3 = 14.
14 mod 12 = 2...Feb.

Then put that back together with the Day/Year etc. to test.

I think you would need to calculate a 'RegDate this Year', and perhaps even 'RegDate next Year' to pick up on those that 'wrap around'.

Or perhaps you can just take the RegDate, grab the MONTH of it (Assuming you don't want to drill down to the day), and test if falls between the given Months you want to test for.

Sorry if that is confusing - I will try to test it once I'm back in the office.

Mal.

On Sunday, August 15, 2021 at 8:30:47 PM UTC+10, Keith Tizzard wrote:
> Ron
>
> 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
>
> I want to find those vehicles whose RegDate anniversary (not the Regdate itself) falls between 7/11/2020 and 14/1/2021
>
> This should produce vehicles
> 235
> 332
> 321
> 665
> 215
>
> Within this the anniversary of 235 is 8/11/2020
> and the anniversary of 215 is 12/1/2021
>
> Hope this explains the issue
> On Saturday, 14 August 2021 at 23:09:30 UTC+1, Ammammata wrote:
> > Il giorno Sat 14 Aug 2021 06:31:52p, *Ron Weiner* ha inviato su
> > comp.databases.ms-access il messaggio news:sf8r5q$1ul$1...@dont-email.me.
> > Vediamo cosa ha scritto:
> > > AnywayI am probably not understanding your requirement.
> > he has been quite clear in his request
> > --
> > /-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
> > -=- -=- -=- -=- -=- -=- -=- -=- - -=-
> > ........... [ al lavoro ] ...........

Re: Need some SQL

<sfb4nj$f2v$1@dont-email.me>

  copy mid

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

  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 09:27:12 -0400
Organization: WorksRite
Lines: 75
Message-ID: <sfb4nj$f2v$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>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Aug 2021 13:27:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1b76ae08641c2632c06c7d414a24e61d";
logging-data="15455"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nbnVVBlpVxFq34Sy3MhWG"
Cancel-Lock: sha1:4v6O7xdJ3AKVSWR9S7apMWoqhUo=
X-Antivirus-Status: Clean
X-Newsreader: MesNews/1.08.06.00-gb
X-Antivirus: AVG (VPS 210814-0, 8/13/2021), Outbound message
X-ICQ: 1701145376
 by: Ron Weiner - Sun, 15 Aug 2021 13:27 UTC

OK... Got it now, and see the problem. I created a table tblVehicle
and put your example records in it. I have a solutions which is really
not all that good. But it gives the correct result set, so any port in
a storm.

Sql for when the date spans 2 years

SELECT tblVehicle.RegDate, tblVehicle.VIN
FROM tblVehicle
WHERE
CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date())-1,[RegDate]))
Between #11/7/2020# And #12/31/2020#
OR CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
Between #1/1/2021# And #1/14/2021#;

If the date span was all in the same year the Sql would be:

SELECT tblVehicle.RegDate, tblVehicle.VIN
FROM tblVehicle
WHERE
CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
Between #1/1/2021# And #1/14/2021#;

If this query happened behind a form than you could prompt for the
dates, see if the start date and end date were in the same year and
select the sql statement accordingly. It’s a little messy I know but
it seems to work. Another problem with this is if the date span was
was this year and next year. Yea this solution sucks. I’ll think on
it more and see if I can come up with something better later. Sorry to
have wasted your time.

Rdub

Keith Tizzard brought next idea :
> Ron
>
> 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
>
> I want to find those vehicles whose RegDate anniversary (not the Regdate
> itself) falls between 7/11/2020 and 14/1/2021
>
> This should produce vehicles
> 235
> 332
> 321
> 665
> 215
>
> Within this the anniversary of 235 is 8/11/2020
> and the anniversary of 215 is 12/1/2021
>
> Hope this explains the issue
>
> On Saturday, 14 August 2021 at 23:09:30 UTC+1, Ammammata wrote:
>> Il giorno Sat 14 Aug 2021 06:31:52p, *Ron Weiner* ha inviato su
>> comp.databases.ms-access il messaggio news:sf8r5q$1ul$1...@dont-email.me.
>> Vediamo cosa ha scritto:
>>> AnywayI am probably not understanding your requirement.
>> he has been quite clear in his request
>> --
>> /-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
>> -=- -=- -=- -=- -=- -=- -=- -=- - -=-
>> ........... [ al lavoro ] ...........

Re: Need some SQL

<sfb9r9$hlb$1@dont-email.me>

  copy mid

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

  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 10:54:33 -0400
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <sfb9r9$hlb$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 14:54:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="31af4b5ddc4f4e1c2a6a4abfbfd38495";
logging-data="18091"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dZJhWggasxgIfVH4BA8ZlNgg+u1z/yRI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:zrlvmENSRYghK4x/tp5o3Vj1+8Y=
In-Reply-To: <sfb4nj$f2v$1@dont-email.me>
Content-Language: en-US
 by: Neil - Sun, 15 Aug 2021 14:54 UTC

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

On 8/15/2021 9:27 AM, Ron Weiner wrote:
> OK... Got it now, and see the  problem.  I created a table tblVehicle
> and put your example records in it. I have a solutions which is really
> not all that good.  But it gives the correct result set, so any port in
> a storm.
>
> Sql for when the date spans 2 years
>
> SELECT tblVehicle.RegDate, tblVehicle.VIN
> FROM tblVehicle
> WHERE CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date())-1,[RegDate]))
>   Between #11/7/2020# And #12/31/2020#
> OR  CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
>    Between #1/1/2021# And #1/14/2021#;
>
> If the date span was all in the same year the Sql would be:
>
> SELECT tblVehicle.RegDate, tblVehicle.VIN
> FROM tblVehicle
> WHERE CDate(DateAdd("yyyy",DateDiff("yyyy",[RegDate],Date()),[RegDate]))
>    Between #1/1/2021# And #1/14/2021#;
>
> If this query happened behind a form than you could prompt for the
> dates, see if the start date and end date were in the same year and
> select the sql statement accordingly.  It’s a little messy I know but it
> seems to work.  Another problem with this is if the date span was was
> this year and next year.  Yea this solution sucks.  I’ll think on it
> more and see if I can come up with something better later.  Sorry to
> have wasted your time.
>
> Rdub
>
>
> Keith Tizzard brought next idea :
>> Ron
>>
>> 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
>>
>> I want to find those vehicles whose RegDate anniversary (not the
>> Regdate itself) falls between  7/11/2020 and 14/1/2021
>>
>> This should produce vehicles
>> 235
>> 332
>> 321
>> 665
>> 215
>>
>> Within this the anniversary of 235 is 8/11/2020
>> and the anniversary of 215 is 12/1/2021
>>
>> Hope this explains the issue
>>
>> On Saturday, 14 August 2021 at 23:09:30 UTC+1, Ammammata wrote:
>>> Il giorno Sat 14 Aug 2021 06:31:52p, *Ron Weiner* ha inviato su
>>> comp.databases.ms-access il messaggio
>>> news:sf8r5q$1ul$1...@dont-email.me. Vediamo cosa ha scritto:
>>>> AnywayI am probably not understanding your requirement.
>>> he has been quite clear in his request
>>> --
>>> /-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\ -=- -=- -=- -=- -=- -=- -=- -=-
>>> - -=- ........... [ al lavoro ] ...........

--
best regards,

Neil

Re: Need some SQL

<sfbb72$9al$1@dont-email.me>

  copy mid

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

  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 11:17:56 -0400
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <sfbb72$9al$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 15 Aug 2021 15:17:54 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="31af4b5ddc4f4e1c2a6a4abfbfd38495";
logging-data="9557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0r9MBs/6cawA2Tug8l1spHP8BbxkiKcg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:PRZjvRJw6tqZANIjInQvEwyuChQ=
In-Reply-To: <sfb9r9$hlb$1@dont-email.me>
Content-Language: en-US
 by: Neil - Sun, 15 Aug 2021 15:17 UTC

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

<sfbdth$1kd$1@dont-email.me>

  copy mid

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

  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 12:03:59 -0400
Organization: WorksRite
Lines: 47
Message-ID: <sfbdth$1kd$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>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Aug 2021 16:04:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1b76ae08641c2632c06c7d414a24e61d";
logging-data="1677"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+bvpmEzyUIsaDBKtTYYMa"
Cancel-Lock: sha1:47S2wYtp5GDchoQRNQjymhDdb3k=
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 16:03 UTC

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

Re: Need some SQL

<sfbhf1$7ei$1@dont-email.me>

  copy mid

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

  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 13:04:35 -0400
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <sfbhf1$7ei$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Aug 2021 17:04:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="31af4b5ddc4f4e1c2a6a4abfbfd38495";
logging-data="7634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GTxrF8C87TQZTrQ1T3PEGEmFU68mAKUs="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:zefu0iLKftgaU7X1VZJmDweC3z8=
In-Reply-To: <sfbdth$1kd$1@dont-email.me>
Content-Language: en-US
 by: Neil - Sun, 15 Aug 2021 17:04 UTC

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

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor