Re: Dateadd in SQL statement not working
From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 05/09/04
- Next message: Bob Barrows [MVP]: "Re: Dateadd in SQL statement not working"
- Previous message: Brandon: "Re: Dateadd in SQL statement not working"
- In reply to: Brandon: "Re: Dateadd in SQL statement not working"
- Next in thread: Brandon: "Re: Dateadd in SQL statement not working"
- Reply: Brandon: "Re: Dateadd in SQL statement not working"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 9 May 2004 09:38:32 -0400
> Error Type:
> Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
> [MERANT][ODBC Sybase driver][SQL Server]Incorrect syntax near 'AL'.
> /page.asp Line 22
Omigod, I thought you said you were using SQL Server, which is what my
advice applied to. Upon reading this error message from the Sybase ODBC
driver (????) I went back to reread your initial message and saw " ... SQL
statement that is functional in Access 2K to work in ASP."
Due to a sloppy initial reading, I missed the "Access" part of your
question, so allow me to revise my answer so it applies to JetSQL (the
version of SQL used by Jet, which is the database usually used by Access):
JetSQL uses the VBA version of DateAdd, so you do need to delimit the
datepart argument. There are two further problems: JetSQL requires date
literals to be delimited by hash marks (#). Also, JetSQL does not recognize
the ISO date format I recommended in my initial message. The "safe" format
that Jet will always recognize is YYYY-MM-DD, so if the database is Jet, the
statement should look like this:
SELECT DateAdd('s', Ticket_Opened_Date, #1969-12-31 20:00:00#) ...
But my confusion is not totally resolved: Why are you using a Sybase ODBC
driver to connect to either a Jet or a SQL Server database? Are you really
connecting to a Sybase database? If so, I have no idea whether either of my
answers applies to a Sybase database. Please clarify what you are doing
here. If you need help with Sybase SQL syntax, you need to find a Sybase
newsgroup or forum, which you probably will not find on the MS public
newsgroup hierarchy. Google can help you find a Sybase newsgroup.
If you are not using a Sybase database, then you need to use the appropriate
OLEDB provider for whatever database you are using. See
www.able-consulting.com/ado_conn.htm for help with the appropriate
connection string.
Bob Barrows
-- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
- Next message: Bob Barrows [MVP]: "Re: Dateadd in SQL statement not working"
- Previous message: Brandon: "Re: Dateadd in SQL statement not working"
- In reply to: Brandon: "Re: Dateadd in SQL statement not working"
- Next in thread: Brandon: "Re: Dateadd in SQL statement not working"
- Reply: Brandon: "Re: Dateadd in SQL statement not working"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|