Bug #1252: Incorrect datetime representation in php3_mssql

From: Date: Sun, 21 Mar 1999 20:45:57 +0000
Subject: Bug #1252: Incorrect datetime representation in php3_mssql
Groups: php.dev 
Request: Send a blank email to php-dev+get-4710@lists.php.net to get a copy of this message
From: balchen@saint-etienne.no Operating system: NT 4.0 build 1381 (SP 3, multi-processor kernel) PHP version: 3.0.6 PHP Bug Type: Other Bug description: Incorrect datetime representation in php3_mssql Datetime fields are represented in MS SQL as 8 byte floating point numbers, and the return value in an SQL query is a 17 byte string, but the module php3_mssql seems to interpret them a an 8 byte string. When executing a command similar to this, list(.., $date, ...) = mssql_fetch_row($result); you get a $date that contains the first 8 bytes of the return value instead of the actual date string. This means that (at least on my system), $date contains "Mar 21 1", whereas the return value from MS SQL is "Mar 21 1999 21:00". date() totally gives up when giving it $date, and returns Jan 01 1970. The only solution is to execute a slightly modified SQL statement, converting the datetime field to a varchar using CONVERT, like this: SELECT CONVERT(varchar(17), datefield) FROM table This will return a 17 byte string that php3_mssql doesn't fuck up. It doesn't like a system-specific problem to me, but anyway: I'm running NT 4.0, SQL Server 6.5, PHP for Win32 3.0.6 using IIS 4.0. -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#4710) next »