Re: Different MSSQL output date format from the same PHP script
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Tue, 19 Feb 2008 06:40:01 -0500
Alessandro wrote:
On 19 Feb, 10:55, Toby A Inkster <usenet200...@xxxxxxxxxxxxxxxxx>
wrote:
Alessandro wrote:I have a Windows Server 2003 R2 SP2 box where MS SQL 2000 SP4 isUsing MSSQL, you are really best off specifying your desired date format
running.
as part of the query itself. e.g.
SELECT CONVERT(varchar(20),my_date,20) AS my_date
FROM my_table
I agree with you approach. Unfortunately I have many queries of this
kind:
SELECT * FROM my_table
and I display datetime columns with instructions like the following:
echo "DATE1: ".date("d/m/Y",strtotime($row[DateTimeColumn1]));
I have to parse all my scripts (too many) and change both the query
and the echo argument...
SELECT * is not a good thing to use. You are much better off always specifying the columns.
For one thing, it's very seldom you need all of the columns. But more importantly, what happens if someone later adds a new column to the table (i.e. a 5mb BLOB)?
Also, if someone later deletes or renames a current column, the query will fail, making the problem very obvious. Otherwise you may not even get an error message, depending on your error settings - just incorrect output, which may or may not be noticed for a while.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: Different MSSQL output date format from the same PHP script
- From: Willem Bogaerts
- Re: Different MSSQL output date format from the same PHP script
- References:
- Different MSSQL output date format from the same PHP script
- From: Alessandro
- Re: Different MSSQL output date format from the same PHP script
- From: Toby A Inkster
- Re: Different MSSQL output date format from the same PHP script
- From: Alessandro
- Different MSSQL output date format from the same PHP script
- Prev by Date: Re: Different MSSQL output date format from the same PHP script
- Next by Date: Re: Help Again: Creating a web link using HTML, php and MySQL. Help
- Previous by thread: Re: Different MSSQL output date format from the same PHP script
- Next by thread: Re: Different MSSQL output date format from the same PHP script
- Index(es):
Relevant Pages
|