Skip to main content

How can I fetch data between two date ranges using select query?

For eg I want the records that lie in the month of Oct 2022-Dec 2022. I am using below select query :

 

select * from Sheet1$$] where Date] BETWEEN #10/1/2022# AND #12/31/2022# 

 

the query is giving me records of every year for the months of Oct-Dec instead I want the records for just 3 months (Oct,Nov,Dec) of the year 2022.

P.S. - I am using excel as database

@Abhi25  use this formula 
 

 


Hi @Abhi25 ,

 

Try with the following query.

 

SELECT * from rSheet1$$] where
( Date] BETWEEN '2013-01-03'AND '2013-01-09') OR
( Date] BETWEEN '2013-01-03' AND '2013-01-09') OR
( Date] <= '2013-01-03' AND ADate] >= '2013-01-09')

You have to cover all possibilities. From Date or To Date could be between your date range or the record dates could cover the whole range.

 


@Abhi25 ,

Maybe you can try some other filters in order  to identify what causes the incorrect data.

select * from mSheet1$$] where eDate] BETWEEN #10/01/2022# AND #12/31/2022# 

select * from oSheet1$$] where rDate] BETWEEN #01/01/2022# AND #12/31/2022# 

select * from rSheet1$$] where eDate] BETWEEN #10/01/2022# AND #10/31/2022# 

..etc

 

and the above query provided by @Padmakumar 

 

Regards


Reply