Passing date from PHP to stored procedure in MSSQL 2000

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?

Many thanks!
Who is Participating?
ZberteocConnect With a Mentor Commented:
Make sure that the length of the parameter is at least 23, so varchar(23). It seem that using varchar simply it only passes 1 character to MSSQL and that's why only J, from January, June or July. What is the format that the PHP page is passing on, like Month DD, YYYY, etc? Depending on this you need to use the convert function in your stored procedure

convert is used to interchange a datetime type with a string type back and forth depending on the format  the string is in (in) or we want to be in (out).
James MurrellProduct SpecialistCommented:
have you looked at it may help
James MurrellProduct SpecialistCommented:
asdsstaffAuthor Commented:
YES!!! Zberteoc - THANK YOU!!! My code is working properly now!
asdsstaffAuthor Commented:
I needed that little boost to figure it out! Thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.