Connecting Tech Pros Worldwide Forums | Help | Site Map

DATE Format

yashiro
Guest
 
Posts: n/a
#1: Mar 25 '08
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

Jerry Stuckle
Guest
 
Posts: n/a
#2: Mar 25 '08

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
==================

Captain Paralytic
Guest
 
Posts: n/a
#3: Mar 25 '08

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.
The Natural Philosopher
Guest
 
Posts: n/a
#4: Mar 25 '08

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.
Richard
Guest
 
Posts: n/a
#5: Mar 25 '08

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


yashiro
Guest
 
Posts: n/a
#6: Mar 25 '08

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
Jerry Stuckle
Guest
 
Posts: n/a
#7: Mar 25 '08

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
==================

Michael Fesser
Guest
 
Posts: n/a
#8: Mar 25 '08

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
Richard
Guest
 
Posts: n/a
#9: Mar 25 '08

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.


Closed Thread