Home > Archive > MS SQL Server ODBC > April 2005 > PhP with ODBC strange error









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PhP with ODBC strange error
Kuido Külm via SQLMonster.com

2005-04-19, 7:23 am

Hello !
From website PHP script calls following MSSQL2000 stored procedure and
in this procedure:

DECLARE @a_pdate DATETIME
DECLARE @a_vuntil DATETIME
SET @a_pdate=GETDATE()
SET @a_vuntil=DATEADD(da
y,30,@a_pdate)

And now for this statement ODBC error appears

SET @a_vuntil = ( SELECT DBO. KUUPAEV_AINULT(@a_vu
ntil) )

PHP Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver]
[SQL Server]The conversion of a char data type to a datetime data type
resulted in an out-of-range datetime value., SQL state 22008 in
SQLExecDirect in ......


Function itselt:
CREATE FUNCTION KUUPAEV_AINULT ( @kuupaev DATETIME )
RETURNS DATETIME
AS /* makes day.month.year format */
BEGIN
DECLARE @a_data DATETIME
DECLARE @c VARCHAR(25)
SET @c=CONVERT(VARCHAR(2
5),@kuupaev,104 )
SET @a_data = CAST(@c AS DATETIME)
RETURN @a_data
END


Any suggestions ?
Kuido

--
Message posted via http://www.sqlmonster.com
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com