Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 25th, 2008, 11:35 AM
yashiro
Guest
 
Posts: n/a
Default DATE Format

Hello
i Have a database in SQLserver.
I am using php to connect to it and to retrieve data from that
database.
I have a table with a column (DATATIME)

where i do :
$result = mssql_query("SELECT date FROM table1") or
die(mssql_error());

while ($row=mssql_fetch_array($result,MSSQL_NUM)){
echo $row[1];
}

i got the data like :

17/mars/2008 10:54
18/mars/2008 15:34

why the default date format is : DD/MON/YYYY HH:ii:ss
where can i change de that default format?
or how can i change that format?

i have tried :
echo ;date("d.m.y HH:i", strtotime($row[1]))

it showed me 01.01.70

thanks
  #2  
Old March 25th, 2008, 12:15 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: DATE Format

yashiro wrote:
Quote:
Hello
i Have a database in SQLserver.
I am using php to connect to it and to retrieve data from that
database.
I have a table with a column (DATATIME)
>
where i do :
$result = mssql_query("SELECT date FROM table1") or
die(mssql_error());
>
while ($row=mssql_fetch_array($result,MSSQL_NUM)){
echo $row[1];
}
>
i got the data like :
>
17/mars/2008 10:54
18/mars/2008 15:34
>
why the default date format is : DD/MON/YYYY HH:ii:ss
where can i change de that default format?
or how can i change that format?
>
i have tried :
echo ;date("d.m.y HH:i", strtotime($row[1]))
>
it showed me 01.01.70
>
thanks
>
This is the format MySQL is returning data. I suggest you try a MySQL
newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  #3  
Old March 25th, 2008, 01:55 PM
Captain Paralytic
Guest
 
Posts: n/a
Default Re: DATE Format

On 25 Mar, 10:28, yashiro <noum...@yahoo.frwrote:
Quote:
Hello
i Have a database in SQLserver.
I am using php to connect to it and to retrieve data from that
database.
I have a table with a column (DATATIME)
>
where i do :
$result = mssql_query("SELECT date FROM table1") or
die(mssql_error());
>
while ($row=mssql_fetch_array($result,MSSQL_NUM)){
echo $row[1];
>
}
>
i got the data like :
>
17/mars/2008 10:54
18/mars/2008 15:34
>
why the default date format is : DD/MON/YYYY HH:ii:ss
where can i change de that default format?
or how can i change that format?
>
i have tried :
echo ;date("d.m.y HH:i", strtotime($row[1]))
>
it showed me 01.01.70
>
thanks
I doubt if the column is DATATIME, it is more likely DATETIME.
Could you export the table schema and post it?
According to the manual for MySQL 5.0, the system variables to change
the default datetime output format is not yet implemented so I'm very
surprised to see an output like this from a DATETIME field.
You should use the MySQL function DATE_FORMAT() to output the field
value as you want it.
  #4  
Old March 25th, 2008, 02:25 PM
The Natural Philosopher
Guest
 
Posts: n/a
Default Re: DATE Format

Captain Paralytic wrote:
Quote:
On 25 Mar, 10:28, yashiro <noum...@yahoo.frwrote:
Quote:
>Hello
>i Have a database in SQLserver.
>I am using php to connect to it and to retrieve data from that
>database.
>I have a table with a column (DATATIME)
>>
>where i do :
>$result = mssql_query("SELECT date FROM table1") or
>die(mssql_error());
>>
>while ($row=mssql_fetch_array($result,MSSQL_NUM)){
>echo $row[1];
>>
>}
>>
>i got the data like :
>>
>17/mars/2008 10:54
>18/mars/2008 15:34
>>
>why the default date format is : DD/MON/YYYY HH:ii:ss
>where can i change de that default format?
>or how can i change that format?
>>
>i have tried :
>echo ;date("d.m.y HH:i", strtotime($row[1]))
>>
>it showed me 01.01.70
>>
>thanks
>
I doubt if the column is DATATIME, it is more likely DATETIME.
Could you export the table schema and post it?
According to the manual for MySQL 5.0, the system variables to change
the default datetime output format is not yet implemented so I'm very
surprised to see an output like this from a DATETIME field.
You should use the MySQL function DATE_FORMAT() to output the field
value as you want it.
That's what I do.
  #5  
Old March 25th, 2008, 03:25 PM
Richard
Guest
 
Posts: n/a
Default Re: DATE Format



----- Original Message -----
From: "yashiro" <noumian@yahoo.fr>
Newsgroups: comp.lang.php
Sent: Tuesday, March 25, 2008 11:28 AM
Subject: DATE Format
Quote:
Hello
i Have a database in SQLserver.
I am using php to connect to it and to retrieve data from that
database.
I have a table with a column (DATATIME)
>
where i do :
$result = mssql_query("SELECT date FROM table1") or
die(mssql_error());
>
while ($row=mssql_fetch_array($result,MSSQL_NUM)){
echo $row[1];
}
>
i got the data like :
>
17/mars/2008 10:54
18/mars/2008 15:34
>
why the default date format is : DD/MON/YYYY HH:ii:ss
where can i change de that default format?
or how can i change that format?
>
i have tried :
echo ;date("d.m.y HH:i", strtotime($row[1]))
>
it showed me 01.01.70
>
thanks
Hi,
I think you should change the date format in SQL server.
It is possible it depends on your locale.

Best to ask in a MS SQL server newsgroup or forum..
Good luck,
Richard


  #6  
Old March 25th, 2008, 03:45 PM
yashiro
Guest
 
Posts: n/a
Default Re: DATE Format

thank you guys
i solve the problem myself
i just have to change de format like this

SELECT CONVERT(VARCHAR, incident.date_, 120) FROM table1

then i am able to show the data as i want using date
date("d.m.y", strtotime($row[0]))

thanks
  #7  
Old March 25th, 2008, 05:15 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: DATE Format

Captain Paralytic wrote:
Quote:
On 25 Mar, 10:28, yashiro <noum...@yahoo.frwrote:
Quote:
>Hello
>i Have a database in SQLserver.
>I am using php to connect to it and to retrieve data from that
>database.
>I have a table with a column (DATATIME)
>>
>where i do :
>$result = mssql_query("SELECT date FROM table1") or
>die(mssql_error());
>>
>while ($row=mssql_fetch_array($result,MSSQL_NUM)){
>echo $row[1];
>>
>}
>>
>i got the data like :
>>
>17/mars/2008 10:54
>18/mars/2008 15:34
>>
>why the default date format is : DD/MON/YYYY HH:ii:ss
>where can i change de that default format?
>or how can i change that format?
>>
>i have tried :
>echo ;date("d.m.y HH:i", strtotime($row[1]))
>>
>it showed me 01.01.70
>>
>thanks
>
I doubt if the column is DATATIME, it is more likely DATETIME.
Could you export the table schema and post it?
According to the manual for MySQL 5.0, the system variables to change
the default datetime output format is not yet implemented so I'm very
surprised to see an output like this from a DATETIME field.
You should use the MySQL function DATE_FORMAT() to output the field
value as you want it.
>
Except this is SQL Server, not MySQL.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  #8  
Old March 25th, 2008, 07:35 PM
Michael Fesser
Guest
 
Posts: n/a
Default Re: DATE Format

..oO(yashiro)
Quote:
>thank you guys
>i solve the problem myself
>i just have to change de format like this
>
>SELECT CONVERT(VARCHAR, incident.date_, 120) FROM table1
>
>then i am able to show the data as i want using date
>date("d.m.y", strtotime($row[0]))
Looks just like an ugly hack. Doesn't your SQL server have its own date
formatting functions?

Micha
  #9  
Old March 25th, 2008, 08:45 PM
Richard
Guest
 
Posts: n/a
Default Re: DATE Format


"Jerry Stuckle" <jstucklex@attglobal.netwrote in message
news:Se-dnWd8bfxrQXXanZ2dnUVZ_v_inZ2d@comcast.com...
Quote:
yashiro wrote:
Quote:
>Hello
>i Have a database in SQLserver.
>I am using php to connect to it and to retrieve data from that
>database.
>I have a table with a column (DATATIME)
>>
>where i do :
>$result = mssql_query("SELECT date FROM table1") or
>die(mssql_error());
>>
>while ($row=mssql_fetch_array($result,MSSQL_NUM)){
>echo $row[1];
>}
>>
>i got the data like :
>>
>17/mars/2008 10:54
>18/mars/2008 15:34
>>
>why the default date format is : DD/MON/YYYY HH:ii:ss
>where can i change de that default format?
>or how can i change that format?
>>
>i have tried :
>echo ;date("d.m.y HH:i", strtotime($row[1]))
>>
>it showed me 01.01.70
>>
>thanks
>>
>
This is the format MySQL is returning data. I suggest you try a
MySQL newsgroup.
>

Except this is SQL Server, not MySQL.


R.


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles