473,231 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

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 3005
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
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
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
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
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
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
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
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
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
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
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.