Skip to main content
Solved

Fetch data between two dates using excel as database


Forum|alt.badge.img+5
  • Navigator | Tier 3
  • 22 replies

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

Best answer by Padmakumar

Hi @Abhi25 ,

 

Try with the following query.

 

SELECT * from [Sheet1$$] 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 [Date] >= '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.

 

View original
Did this topic help answer your question?

3 replies

rbkadiyam
Premier Pathfinder | Tier 7
Forum|alt.badge.img+17
  • Premier Pathfinder | Tier 7
  • 590 replies
  • January 3, 2023

@Abhi25  use this formula 
 

 


Padmakumar
Forum|alt.badge.img+14
  • Flight Specialist | Tier 4
  • 786 replies
  • Answer
  • January 4, 2023

Hi @Abhi25 ,

 

Try with the following query.

 

SELECT * from [Sheet1$$] 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 [Date] >= '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.

 


Raul Jaimes
Forum|alt.badge.img+9
  • Navigator | Tier 3
  • 494 replies
  • January 4, 2023

@Abhi25 ,

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

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

select * from [Sheet1$$] where [Date] BETWEEN #01/01/2022# AND #12/31/2022# 

select * from [Sheet1$$] where [Date] BETWEEN #10/01/2022# AND #10/31/2022# 

..etc

 

and the above query provided by @Padmakumar 

 

Regards


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings