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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement issue

Status
Not open for further replies.

Mdiaz

Programmer
Jul 8, 2002
32
0
0
US
I am having a problem with the following statement. Can you folks help out?

sqlstatement="SELECT EventDate, detail FROM calendar WHERE (((DatePart('ww',EventDate))=" & datepart("ww",Date()) & " And ChapterID=" & Session("Chapter") & ")) ORDER BY EventDate"

I am getting the following error:

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid parameter 1 specified for datepart.

Thanks.
 
As Jay points out, it's those quotes (single and double) around the ww in the DATEPART. The datepart (ww, dd, etc) is NOT a string. It's a TSQL command (or a portion of it), so it doesn't go in quotes.

-SQLBill
 
Thanks for your help.

OK, I made the changes and now I'm getting the following error: Invalid procedure call or argument: 'DatePart'

Here is the entire section of code:

If Session("ChapterID")<>"" Then
sqlstatement="SELECT EventDate, detail FROM calendar WHERE (((DatePart(ww,[EventDate]))=" & datepart(ww,Date()) & " And ChapterID=" & Session("ChapterID") & ")) ORDER BY EventDate"
Else
sqlstatement="SELECT EventDate, detail FROM calendar WHERE (((DatePart(ww,[EventDate]))=" & datepart(ww,Date()) & " And ChapterID=1)) ORDER BY EventDate"
End If


I think we are close...
 
use getdate() instead of Date(), and I Think there is a bracket missing here:

(((DatePart(ww,[EventDate]))
Should be
(((DatePart(ww,[EventDate])))="





Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top