Jump to content

Archived

This topic is now archived and is closed to further replies.

PWD

Displaying results from MySQL DATE_FORMAT()

Recommended Posts

I must be missing something basic and I have had 2 hours of sleep the last two days trying to figure this DATE_FORMAT function out...

My Table Structure:

[b]Table:[/b] imp_dates
[b]Field 1:[/b] date_date DATE not null
[b]Field 2:[/b] date_info varchar 250 not null

My basic query (which is an include since this information is accessed on more than a dozen pages):

[code]<?php
$connect = mysql_connect("localhost","User","Pass")
    or die("<h1>Invalid Username and/or Password</h1>");

mysql_select_db("data")
    or die("<h1>Could Not Connect to Database</h1>");

$query = "Select DATE_FORMAT('date_date','%b %d %Y') AS date_date,date_info from imp_dates ORDER BY date_date ASC";
$result = mysql_query($query)
    or die(mysql_error());
?>[/code]

My static webpage:

[code]/* html markup */
<?php

while($row = mysql_fetch_assoc($result)) {
extract($row);


?>

/*Some html mark up*/

<li><?php echo $date_date; ?></li>
<li><?php echo $date_info; ?></li>

<?php

}

?>[/code]

The date doesn't display AT ALL, but the info. snippet does...I'm simply trying to display the date in a format that is easier to read than int'l date format using the DATE_FORMAT() function. Where am I going wrong?

My gratitude ahead of time for helping me learn...again...

Share this post


Link to post
Share on other sites
$query = "Select DATE_FORMAT(date_date,'%b %d %Y') AS date_date,date_info from imp_dates ORDER BY date_date ASC";

No quotes in the field name :)

Share this post


Link to post
Share on other sites
DOH!

Thank you for the second pair of eyes!

[!--sizeo:3--][span style=\"font-size:12pt;line-height:100%\"][!--/sizeo--][b]Can I express my gratitude enough?[/b]
[!--sizec--][/span][!--/sizec--]

Works perfectly...

Share this post


Link to post
Share on other sites
not a problem, sometimes it just takes someone else to see it, happens to me all the time :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.