Passing date from PHP to stored procedure in MSSQL 2000
Posted on 2008-11-13
Hi everybody -
I've reached the extent of my tolerance for google searches, and am in need of some help.
I am passing a datetime variable from PHP to a MSSQL (2000) stored procedure. When passing the date, I am using the datatype varchar, as datetime is apparently not an option in MSSQL. I have tried a slew of 'convert' options, but can not seem to get the varchar back into a datetime format to allow my query to work. I error out with: Syntax error converting datetime from character string. (severity 16).
I've also tried different data types:
When I look at the 'date' MSSQL receives from PHP as VARCHAR, ther result is 'J'.
When I look at the 'date' MSSQL receives from PHP as SQLINT4, ther result is '0'.
When I try to pass the 'date' as text, the stored procedure says text 'cannot be compared or sorted , execpt when using IS NULL or LIKE operator'. This won't work, beacuse I need to have a range within 2 seperate exact dates.
It seems that varchar is my best best, but I'm open to other ideas.
The main goal that I am trying to accomplish is to get a date which has been entered on a webpage (in PHP) to run in a stored procedure in (MSSQL 2000) and create a temporary table based on the date from PHP. Any ideas?