By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

Date issue in php and mysql

P: n/a
$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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
>
"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

P: n/a
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

P: n/a
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

P: n/a
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.