Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP WITH SQL STATEMENT

Status
Not open for further replies.

MoaD

Programmer
Apr 17, 2002
17
CA
Ok i have a table with a date/time field in an access database. i want to extract only the date but i want to do it all in the sql statement so what im trying is this

strSQL = "SELECT DISTINCT SUBSTRING( datDate, 1, 10 ) FROM tblDate"


asp is not recognizing the substring command in the sql statement?

does asp not support the substring sql command? or am i doing something else wrong
 
The way you've used it, ASP doesn't really have to recognize it at all. It merely passes it over to the SQL server. As long as the SQL server knows what SUBSTRING is, it'll work.

What is the error/problem that you're running into?
 
actually asp isn't having trouble with your sql statement, access is. Try this:

strSQL = "SELECT DISTINCT LEFT( datDate, 10 ) FROM tblDate"

In vbScript (asp) you need the MID() function (there is no SUBSTRING() function....

strSQL = "SELECT DISTINCT MID( datDate, 1, 10 ) FROM tblDate" would also work -----------------------------------------------------------------
"Whether you think that you can, or that you can't, you are usually right."
- Henry Ford (1863-1947)

mikewolf@tst-us.com
 
ha i wasn't even thinking of mid Oops

ty for all the help mid worked great
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top