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!
asdsstaffAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

James MurrellProduct SpecialistCommented:
have you looked at http://www.daniweb.com/forums/thread112159.html it may help
0
James MurrellProduct SpecialistCommented:
0
ZberteocCommented:
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

http://msdn.microsoft.com/en-us/library/ms187928.aspx

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).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
asdsstaffAuthor Commented:
YES!!! Zberteoc - THANK YOU!!! My code is working properly now!
0
asdsstaffAuthor Commented:
I needed that little boost to figure it out! Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.