FIND with BETWEEN

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
robleer
Posts: 285
Joined: Wed Jul 14, 2010 7:01 pm

FIND with BETWEEN

Post by robleer »

Hi,

I have a simple problem which I cannot solve (maybe I'm staring to long at a simple thing :) )

This works:
FIND OpslagContractDatum WHERE OpslagContractDatum.Datum>=CURRENT_DATE-3

This works:
FIND OpslagContractDatum WHERE OpslagContractDatum.Datum<=CURRENT_DATE+3

This does not work (no rows returned):
FIND OpslagContractDatum WHERE OpslagContractDatum.Datum>=CURRENT_DATE-3 AND OpslagContractDatum.Datum<=CURRENT_DATE+3



This does NOT work
FIND OpslagContractDatum WHERE OpslagContractDatum.Datum BETWEEN (CURRENT_DATE-3) AND (CURRENT_DATE+3)

This works (but is useless of course:
FIND OpslagContractDatum WHERE OpslagContractDatum.Datum BETWEEN (CURRENT_DATE) AND (CURRENT_DATE)


TIA,

Rob
Using 8.7 Professional 3025 on MySQL/Windows
robleer
Posts: 285
Joined: Wed Jul 14, 2010 7:01 pm

Re: FIND with BETWEEN

Post by robleer »

I found a solution myself

This works:

FIND OpslagContractDatum WHERE
OpslagContractDatum.Datum BETWEEN DATE_ADD (CURRENT_DATE, -3) AND DATE_ADD (CURRENT_DATE, 3)
Using 8.7 Professional 3025 on MySQL/Windows
joben
Posts: 221
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: FIND with BETWEEN

Post by joben »

robleer wrote: Thu Sep 29, 2022 8:51 am I found a solution myself

This works:

FIND OpslagContractDatum WHERE
OpslagContractDatum.Datum BETWEEN DATE_ADD (CURRENT_DATE, -3) AND DATE_ADD (CURRENT_DATE, 3)
I was just about to post this suggestion :D

My experience is that this way of writing the query tends to work better.
Regards, Joakim

Image
Post Reply