That's not supposed to cause an error because the syntax for dateadd is
DATEADD(datepart, number, date)
where the abbreviation for datepart can be day,dd or d (see Books Online). To make sure, just type DATEADD(d, 30, getdate()) in Query Analyser and see that it passes, so I think that the problem is somewhere else.
Format function doens't exists in SQL2000. Try using CONVERT or CAST, like, for instance:
CONVERT(VARCHAR, DATEADD(d, 30, your_date), 103)
Bottom line, the SQL statement to pass to SQL Server (BTW you can store it in a
VB string var) would be:
Dim strSQL as String
strSQL = "Select * from arcusfil_sql where convert(datetime,user_def_fld_3) > CONVERT(DATETIME, DATEADD(d, 30, " & _
your_vb_date_var & "), 103)"
rs1.Open strSQL, Conn
Quote:
Originally posted by air_salak
Taking away the double quote will cause the 'd' to be not defined. Thus the error "variable not defined" appear.
As you can see, I'm using VB to run this SQL statement. Any other idea?
Thanks,
John
|