Re: Different MSSQL output date format from the same PHP script



Alessandro wrote:

I have a Windows Server 2003 R2 SP2 box where MS SQL 2000 SP4 is
running.

Using MSSQL, you are really best off specifying your desired date format
as part of the query itself. e.g.

SELECT CONVERT(varchar(20),my_date,20) AS my_date
FROM my_table

will consistently return dates as varchar(20) columns formatted in "YYYY-
MM-DD HH:mm:ss" format. If you don't include the format conversion in the
query itself, then the format you get back can be a bit unpredictable. It
will depend on, amongst other factors: version of PHP, version of FreeDTS,
locale settings and the user name used to log into SQL server.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 20 days, 16:08.]

Bottled Water
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
.



Relevant Pages

  • Re: formatting a calculated number field on a form
    ... > A query in an MDB file CAN call a user-defined function. ... > function name is Age and it returns a double. ... The user will certainly "notice" if a patient was born on Jan ... I just want control over the *display format* of a number ...
    (microsoft.public.access.forms)
  • RE: Query count then average.
    ... What was happening in my database was the query returned the ... "Ken Sheridan" wrote: ... It probably depends where you set the Format property. ... "Robert F." ...
    (microsoft.public.access.queries)
  • RE: Cannot get code to work for API Save Dialog Box
    ... I got it working to format correctly now. ... that table in my other queries and union query. ... The code is actually working by giving me the totals I need. ... The first spreadsheet placed where I told it to be contains the incorrect ...
    (microsoft.public.access.forms)
  • RE: Excel & MS Query caused compile errors
    ... My data is in an Excel file called ... The format of it were distorted after copying and pasting. ... Microsoft SQL Server 2000, which requires a server, VBA or Microsoft Query ...
    (microsoft.public.excel.programming)
  • Re: date problem
    ... I store a date (format mm/dd/yyyy) on MsSQL in a datetime field. ... mysql> CREATE TABLE test2; ... Query OK, ...
    (comp.lang.php)