cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for help on writing a SQL query for OLEDB

Miya
Level 5
Hi,

   Currently i am using OLEDB database to open an excel with name "excel" and  "2 columns" as , start date and  end date , currently iam using the below SQL query to extract the values of the rows with todays date as below
"SELECT * FROM [Excel$] WHERE [Start date] Like '%" & [Today] & "%'"

please can some one help me to get the SQL query for extracting the rows with dates between the start date and end date

Thankyou,
Miya

------------------------------
Miya
------------------------------
3 REPLIES 3

PabloSarabia
Level 11
Hi @Miya

In this case, you want to filter dates, so need to use any of this operators: >, <, =, >=, <= or <>

LIKE operator is used when you have text

So, you correct syntax looks like this:

SELECT * FROM [Excel$] WHERE [Start date] = DATE()

You can use the internal function of OLEDB SQL "DATE()" to get the current date. (Its the same as giving a Data Item value with Today())




Hope this helps you, and if this solves the problem, remember mark as best message

See you in the community, bye 🙂

------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
634726270
------------------------------

Hi Pableo.

  Thank you, actually iam looking for query where i need to filter the values between 2 columns when the column values fall in todays date. For eg column1 date is 28 feb 2022, column 2 date is 3rd march this particular row should get selected.

Miya

------------------------------
Miya
------------------------------

Hi M,

If I understand your requirements correctly, you have to check both columns for your date.
Something in style with:
SELECT * FROM [Excel$] WHERE ([Start date] <= DATE() AND [End date] >= DATE())

If I'm totally off here, then I do not understand what you are trying to select...

------------------------------
Happy coding!
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)