470,849 Members | 1,037 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

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 2934
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by toedipper | last post: by
9 posts views Thread by TC | last post: by
2 posts views Thread by Donald Campbell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.