LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Adding "And" clause in SQL string causing SQL Syntax error

"Android" wrote ...

Have not tried the BETWEEN statement.


Give it a go.

The data comes from Access tables. Knowing this, is there a better way to
compare dates in this scenario without converting to a text string?


Think about it: the SELECT query is one long string. So, in this
scenario you *must* convert it to a string. Using the # characters
(e.g. #01 JUN 2004#) tells the Jet SQL parser it is a date. Depending
on various settings, you could probably get away with '06/01/2004' by
why run the risk when #01 JUN 2004# is unambiguous?

FWIW you could use a native VB Date value as a parameter in an ADO
Command object, but even then under the hood I would wager it was
convert the value to a string for the sake of the SQL parser.

Jamie.

--
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
Converting "uppercase" string data to "lower case" in CSV file [email protected] Excel Discussion (Misc queries) 2 August 12th 08 08:36 PM
nested if contains a syntax error because of a "." Janis Excel Discussion (Misc queries) 3 September 5th 07 04:51 PM
Problem with SQL "Like" clause in Excel Rone Charts and Charting in Excel 0 March 15th 06 12:48 AM
"string too long" error message dick Excel Discussion (Misc queries) 0 January 4th 06 11:02 AM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"