#32022 [Bgs->Opn]: Wrong implementation of mssql.datetimeconvert=Off

From: Date: Fri, 18 Feb 2005 15:39:55 +0000
Subject: #32022 [Bgs->Opn]: Wrong implementation of mssql.datetimeconvert=Off
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-74276@lists.php.net to get a copy of this message
ID: 32022 User updated by: akukula at navopgd dot pl Reported By: akukula at navopgd dot pl -Status: Bogus +Status: Open Bug Type: MSSQL related Operating System: Mandrake Linux 10.1 PHP Version: 4.3.8 New Comment: This is not bogus and I ask you to apply this simple fix. This sprintf() violates dbdatecrack() specification. sprintf() prints invalid date and recompilation of external library is not a fix. Previous Comments: ------------------------------------------------------------------------ [2005-02-18 16:20:08] fmk@php.net FreeTDS should be compiled using --enable-msdblib if you are compiling php with --with-mssql. ------------------------------------------------------------------------ [2005-02-18 16:03:22] akukula at navopgd dot pl Description: ------------ Turning off mssql.datetimeconvert causes dates returned from SQL queries to be shifted one month back. The bug is in line 892 of php_mssql.c,v 1.86.2.41 According to description found in: <http://manuals.sybase.com/onlinebooks/group-cnarc/cng1110e/dblib/@Generic__BookTextView/15105;pt=39614> dbdatecrack() returns month in range 0...11. So in sprintf() the argument dateinfo.month should become dateinfo.month+1 Reproduce code: --------------- mssql_query("SELECT CONVERT(DATETIME, '2005-01-01')"); $a = mssql_fetch_row($res); echo $a[0] . "\n"; mssql_query("SELECT CONVERT(DATETIME, '2005-12-01')"); $a = mssql_fetch_row($res); echo $a[0] . "\n"; Expected result: ---------------- 2005-01-01 00:00:00 2005-12-01 00:00:00 Actual result: -------------- 2005-00-01 00:00:00 2005-11-01 00:00:00 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32022&edit=1

« previous php.bugs (#74276) next »