views:

85

answers:

2

Hello all,

I am using the SQL Server PHP Driver, I think this question can be answered without knowing what this is.

I have come across this many times, what does it mean by NAMES? Column names?:

SET NAMES utf8

Is there a query similar to the above that will get my dates to be returned as a string? For some reason on my SQL Sever 2008 on Vista, this works:

$connectionInfo = array('Database' => $dbname, 'ReturnDatesAsStrings' => true)

But the above 'ReturnDatesAsStrings' does not work on my SQL Server 2005 on a windows server machine? I can't execute any queries after setting the above! It gives me this error:

Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -1 [code] => -1 [2] =>
Invalid option ReturnDatesAsStrings was passed to sqlsrv_connect. [message] => 
Invalid option ReturnDatesAsStrings was passed to sqlsrv_connect. ) ) 

Does SQL Server 2005 support ReturnDatesAsStrings? Is there some other parameter I can pass to do the same?

Thanks all for any help

EDIT

I should of mentioned this but if there is a solution I am hoping for one that is in the form of a setting that can be set before any queries can be executed as I do not have control on what queries will be executed.

+1  A: 

If you want to return a date as a string, you can convert it

SELECT CONVERT (VarChar (30), DateTimeColumn, 121) as DateTimeColumnString

read more here

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

Raj More
I was hoping there was a setting instead of an actual cast - I don't have control of the SQL queries executed but anything that is executed should have its dates returned as a string.
Abs
+2  A: 

I suspect your problem is an old driver. The 'ReturnDatesAsStrings' feature was added in version 1.1, so you probably have 1.0 and just need to upgrade.

Gabe
Ah I see. So this functionalities advisability is dependent on the PHP SQL Server driver! You are right I think as I have the latest driver on my laptop and because our server is running an older version of PHP (5.2.9) - I am using an older driver. Not sure what version though.
Abs
Genius! You are right, just upgraded! Thank you.
Abs