Hi,

I am facing some weird results when querying a MSSQL 2008 server, giving
me just plain wrong results like "2012-01-01 32747:02" (usage of
"mssql_fetch_assoc" originates from the original code fragment):

Here's what I do:

--------CUT---------
<?php
ini_set( 'mssql.datetimeconvert', false );
$dbh = mssql_pconnect( "mssql.example.com", "foor", "bar" );
mssql_select_db( "foobar", $dbh );
$query = "SELECT GETDATE() AS broken";
$sth = mssql_query( $query, $dbh );
$resultArray = array();
while ( $row = mssql_fetch_assoc( $sth ) ) {
  print "datetimeconvert false - broken date: ".$row['broken']."<br>\n";
}

ini_set( 'mssql.datetimeconvert', true );
$query = "SELECT GETDATE() AS good";
$sth = mssql_query( $query, $dbh );
$resultArray = array();
while ( $row = mssql_fetch_assoc( $sth ) ) {
  print "datetimeconvert true - date ok: ".$row['good']."<br>\n";
}
--------CUT---------

When run in a browser, I get this:

--------CUT---------
mssql.datetimeconvert false - broken date: 2012-01-01 32659:02
mssql.datetimeconvert true - date ok: Jan 30 2012 04:01:35:903PM
--------CUT---------

On the other hand, when I run the script via CLI, I get this

--------CUT---------
mssql.datetimeconvert false - broken date: 2012-01-01 00:02:16<br>
mssql.datetimeconvert true - date ok: Jan 30 2012 04:01:35:903PM<br>
--------CUT---------

When mssql.datetimeconvert is false, the date is just completely wrong
... any ideas?

Some stats:

"vanilla" and up2date fedora core 16
apache 2.2.21
php-5.3.8-3.fc16.x86_64 with
php-mssql-5.3.8-3.fc16.x86_64
freetds-0.91-1.fc16.x86_64

With regrads to freetds, I am not having any troubles retrieving
datetime information using the JTDS JDBC driver.

Udo

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to