473,508 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date issue in php and mysql

$result = mysql_query("SELECT ID, tekst, date_format(dato, '%Y %m %d') FROM
henriks ORDER BY ID DESC LIMIT 0,3");

Why doesn't my date show when I print the result?

Ricki
Jul 16 '05 #1
5 3010
On Mon, 25 Aug 2003 12:59:19 +0200
"Ricki Susic" <ri*************@webfabrikken.net> wrote:
$result = mysql_query("SELECT ID, tekst, date_format(dato, '%Y %m
%d') FROM
henriks ORDER BY ID DESC LIMIT 0,3");

Why doesn't my date show when I print the result?

Ricki


You will have to be a little more specific about "Why doesn't my date
show...". Mabey you could copy and paste the offending code to the ng.

Also I would probably do the query as such:

"SELECT ID,tekst DATE_FORMAT(dato, '%Y %m %d') as dato FROM ..."

Matt

--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9688 2894 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #2
>
"SELECT ID,tekst DATE_FORMAT(dato, '%Y %m %d') as dato FROM ..."


Hi Matt,

That was it! Now it works out fine. I'm a little confused though - why
should it be necessary to define the column twice:
DATE_FORMAT(column_name, '%d %m %Y') as column_name in ..........

You know what I mean?!

Ricki
Jul 16 '05 #3
On Mon, 25 Aug 2003 13:46:02 +0200
"Ricki Susic" <ri*************@webfabrikken.net> wrote:

"SELECT ID,tekst DATE_FORMAT(dato, '%Y %m %d') as dato FROM ..."


Hi Matt,

That was it! Now it works out fine. I'm a little confused though - why
should it be necessary to define the column twice:
DATE_FORMAT(column_name, '%d %m %Y') as column_name in ..........

You know what I mean?!

Ricki


You never actually said "SELECT dato ", you asked MySQL "SELECT
DATE_FORMAT(...)". If you didn't give the return vale from the function
a name the column name would be"DATE_FORMAT(column_name,'%d %m
%Y')", it should be said that you can call that column anything you like
(except a reserved word I would guess). It is my own personal
preference to call the return value the same name as the column you are
passing as a parameter.

Maybe to keep MySQL fast the developers droped out needless code which
doesn't bother to give the return value from a function a name(i.e
expr1, ala Access.)

(*wipes brow* hoping the above makes some sort of sense)

Matt

--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9688 2894 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #4
You never actually said "SELECT dato ", you asked MySQL "SELECT
DATE_FORMAT(...)". If you didn't give the return vale from the function
a name the column name would be"DATE_FORMAT(column_name,'%d %m
%Y')", it should be said that you can call that column anything you like
(except a reserved word I would guess). It is my own personal
preference to call the return value the same name as the column you are
passing as a parameter.

Maybe to keep MySQL fast the developers droped out needless code which
doesn't bother to give the return value from a function a name(i.e
expr1, ala Access.)

(*wipes brow* hoping the above makes some sort of sense)

Matt

- Jeremy S. Anderson

I don't know if it makes sense but now I know! Thank you ;-)

Ricki
Jul 16 '05 #5
Matthew Vickers wrote:
On Mon, 25 Aug 2003 13:46:02 +0200
"Ricki Susic" <ri*************@webfabrikken.net> wrote:

"SELECT ID,tekst DATE_FORMAT(dato, '%Y %m %d') as dato FROM ..."

Hi Matt,

That was it! Now it works out fine. I'm a little confused though - why
should it be necessary to define the column twice:
DATE_FORMAT(column_name, '%d %m %Y') as column_name in ..........

You know what I mean?!

Ricki

You never actually said "SELECT dato ", you asked MySQL "SELECT
DATE_FORMAT(...)". If you didn't give the return vale from the function
a name the column name would be"DATE_FORMAT(column_name,'%d %m
%Y')", it should be said that you can call that column anything you like
(except a reserved word I would guess). It is my own personal
preference to call the return value the same name as the column you are
passing as a parameter.

Maybe to keep MySQL fast the developers droped out needless code which
doesn't bother to give the return value from a function a name(i.e
expr1, ala Access.)

Thank God... (any)
There is nothing less informative than expr1.
(*wipes brow* hoping the above makes some sort of sense)

Matt

Jul 16 '05 #6

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

Similar topics

4
26337
by: MyOracle | last post by:
Hi everybody, I just curious about change date(0000-00-00) to date (00-00-0000) in mysql.Can anyone tell me about that. Thanks. izmanhaidi.
2
10061
by: toedipper | last post by:
Hello, I have the following section of php code which updates a mysql record from a form. For the values of livedate and livetime I need to insert the current_date() and current_time()...
0
1469
by: Manny | last post by:
Great that worked! I would also like to only provide a date in the where clause and not a timestamp (the field is of type datetime). I have tried using the date function but it does not appear...
12
13835
by: Emi Lu | last post by:
Hello all, I have a question about "date" & "timestamp" types in PostgreSQL. I want to setup the default value '0000-00-00' and "0000-00-00 00:00:00" for them. However, it seems that PostgreSQL...
2
1655
by: webmonkie | last post by:
Hi, I am hoping someone can point me in the right direction as I have been trying to fix this issue for a good while now. I am trying to take information out of a xml file using php and parsing it...
7
3469
hodgeman
by: hodgeman | last post by:
Hello thescripts forums users... I've found a lot of answers to problems I've had in the past from this forum, and this is the first mySQL query issue I haven't been able to find an answer from...
9
1676
by: TC | last post by:
Hi. I have some ASP written in VB.net which is currently installed on a customers server. The asp connects to a local MySql database and retrieves data for the customers customers. If you see...
10
3994
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
2
518
by: Donald Campbell | last post by:
I am looking at moving some old database systems to MySQL and I am currently working on data loading using mysqlinport. I have an issue with dates as all the data that is coming my way has dates...
3
3527
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
0
7225
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,...
0
7123
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...
0
7498
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...
1
5053
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...
0
4707
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...
0
3194
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.