473,700 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("SE LECT date FROM table1") or
die(mssql_error ());

while ($row=mssql_fet ch_array($resul t,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
Mar 25 '08 #1
8 2951
yashiro wrote:
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("SE LECT date FROM table1") or
die(mssql_error ());

while ($row=mssql_fet ch_array($resul t,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.
js*******@attgl obal.net
=============== ===

Mar 25 '08 #2
On 25 Mar, 10:28, yashiro <noum...@yahoo. frwrote:
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("SE LECT date FROM table1") or
die(mssql_error ());

while ($row=mssql_fet ch_array($resul t,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.
Mar 25 '08 #3
Captain Paralytic wrote:
On 25 Mar, 10:28, yashiro <noum...@yahoo. frwrote:
>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("SE LECT date FROM table1") or
die(mssql_erro r());

while ($row=mssql_fet ch_array($resul t,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.
Mar 25 '08 #4


----- Original Message -----
From: "yashiro" <no*****@yahoo. fr>
Newsgroups: comp.lang.php
Sent: Tuesday, March 25, 2008 11:28 AM
Subject: 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("SE LECT date FROM table1") or
die(mssql_error ());

while ($row=mssql_fet ch_array($resul t,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
Mar 25 '08 #5
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
Mar 25 '08 #6
Captain Paralytic wrote:
On 25 Mar, 10:28, yashiro <noum...@yahoo. frwrote:
>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("SE LECT date FROM table1") or
die(mssql_erro r());

while ($row=mssql_fet ch_array($resul t,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.
js*******@attgl obal.net
=============== ===

Mar 25 '08 #7
..oO(yashiro)
>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
Mar 25 '08 #8

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Se******** *************** *******@comcast .com...
yashiro wrote:
>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("SE LECT date FROM table1") or
die(mssql_erro r());

while ($row=mssql_fet ch_array($resul t,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.
Mar 25 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
43008
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to mediate between webapps and arbitrary database backends using JDBC. I am very unwilling indeed to write special-case code for particular databases. Our code has worked satisfactorily with many databases, including many instances MS SQLServer 2000...
2
5060
by: amith | last post by:
hi I have written javascript for comparing two dates in US format and finding out whether the start date is greater than the end date and vice versa. In this attempt i have instantiated the date object with the date string which the user inputs from a pop up calendar. somewhat like this..........
4
5385
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
3
11580
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not overlap existing records from the same table. I had this all working some time ago, but recently when I have gone back to do more testing, part of these validations no longer work. While there have been changes to the code in the meantime, I cannot...
5
816
by: Macca | last post by:
Hi, I have a table which has a date/time field. I am storing them as follows :- 01/01/2005 11:25 01/01/2005 19:44 02/01/2005 05:04
12
29459
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as follows: function doDateCheckNow(source, args) { var oDate = document.getElementById(source.controltovalidate); // dd/mm/yyyy
20
35570
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the project the date format in vb.code ( not in Windows) and how can I find out which date format the PC Windows is using. Thanks for any response
30
5701
by: fniles | last post by:
On my machine in the office I change the computer setting to English (UK) so the date format is dd/mm/yyyy instead of mm/dd/yyyy for US. This problem happens in either Access or SQL Server. In the database I have a table with Date/time column. The database is located on a machine that is set to dd/mm/yyyy also. When I enter date 7/1/08 (as in January 7, 2008), it stores it in the database as 1/7/08 instead of 7/1/08. Why is it like that...
4
3055
by: OzNet | last post by:
I have some functions to calculate the working days in a given period. This includes a table that is queried to calculate the number of public holidays that don’t occur on a weekend. If I test the function using the intermediate window, it works fine. However, when I pass the dates from the code attached to my form, the results are inaccurate. You will notice my dates are in Australian format. Everything works fine using the Australian...
11
6190
ollyb303
by: ollyb303 | last post by:
Hello, I am using a dynamic crosstab report to track performance statistics for my company and I have hit a problem. I would like the option to track stats daily (for the last 7 complete days), weekly (for the last 6 weeks) and monthly (for the last 6 complete months). Daily and monthly are not causing me a problem - I have used the following code to construct the query: strXT = "TRANSFORM Sum(Query2.STAT) AS SumOfSTAT " & _...
0
8726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8645
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5903
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4404
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2028
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.