Looking for help on writing a SQL query for OLEDB
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-02-22 05:02 AM
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
------------------------------
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-02-22 08:08 AM
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
------------------------------
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
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-03-22 03:33 AM
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
------------------------------
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
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
02-03-22 08:49 AM
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
------------------------------
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!)
Paul, Sweden
(By all means, do not mark this as the best answer!)
