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

stored procedure and a date

Status
Not open for further replies.

hithere

Programmer
Jul 12, 2001
214
US
passing a date value from asp (coded in vbs) to a stored procedure. stored procedure doesn't like the /'s in the date. creating date like this:
dateshow = formatdatetime(DateAdd("d",-4,now()), vbShortDate)
tried converting it to a string and changing the declaration varchar(60) in the proc. no luck.
thoughts? (or better yet, solution?)
mb "Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!"
Marvin the Martian
 
The stored procedures I have don't have any problems with the dates.

It could be the local settings of your SQL server.

Also I assume you send the dates in single quotes just like varchars (i.e. EXEC sp_my_sp intParam,'varChar','10/5/2003')

Also if you use any forms that allows you to enter a date, make sure they don't enter something like 2/29/2003 - it'll give you invalid date error.

What error you get BTW?
 
I always pass dates to SQL stored procedures as strings and as long as the string is in a valid date format, including 'dd/mm/yyyy', no problems. I also use 'SET DATEFORMAT mdy' in the storered procedure to overide the local server date setting just in case.
 
error I'm getting:
SQL Server error '80040e14'
Line 1: Incorrect syntax near '/'.

which is due to the date being 3/15/03

as you can see from my first post, the date is dynamically created in the page like this:

dateshow = formatdatetime(DateAdd("d",-4,now()), vbShortDate)

tried converting to string like this:

dateshow = cstr(dateshow)

so no, there aren't '' around the string...I'll try concatenating it and see if that works and also try adding the set dateformat thing and see if that works "Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!"
Marvin the Martian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top