TO_CHAR and BETWEEN Operator in my SQL Code

JrExceler

New Member
Joined
Nov 18, 2016
Messages
17
Hello Everyone,

I'm using SQL to get data from Access to my Excel Sheet, but I want to use the invoice date to have another filter criteria,
Do you know how can it be done?

I'm trying to convert the Invoice Date with:
" TO_CHAR(`Invoice Date`, 'YYYYMMDD')," & _
and then use BETWEEN in my Query,
however, it's giving me error.

¿is there any other way to get it?

This is my original Code that is Working,
But I cannot make it work with BETWEEN operator.

Any idea?


Code:
SQL0 = " SELECT " & _
        " Mat," & _
        " `Vol`," & _
        " Mon," & _
        " `Invoice Date`," & _
        " `Group`," & _
        " Dest," & _
        " source," & _
        " Sales"


SQL7 = " FROM `C:\Sales\NSalesAc.accdb`.NSales" & _
  " WHERE `Group` = '" & MODL & "' " & _
  " AND Dest = '" & MKT & "' "

     SQL = SQL0 + SQL7
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
you might want to consider using group in a query as it usually has a specific meaning

Have you tried to hardcode the date first in the SQL, then see how best to substitute the values
 
Last edited:
Upvote 0
Note: TO_CHAR is not an MSAccess function.
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,221,710
Messages
6,161,445
Members
451,706
Latest member
SMB1982

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top