Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL DATE_FORMAT()

Status
Not open for further replies.

Deleted

Technical User
Jul 17, 2003
470
US
Got a problem with query output using perl

my $query = "SELECT id, handle, DATE_FORMAT(insert_date, '%l:%i:%S %p') FROM session ORDER BY insert_date";
my $sth = $dbh->prepare($query);
$sth->execute;
my $data = $sth->fetchrow_hashref;

print "$data->{insert_date}";

The issue is that when I query the results as a hashref or arrayref_all the 'field name (insert_date)' returns a undef value.

Any suggestions?

 
try assigning the column an alias name in the sql, then using that name in your script
Code:
SELECT id
     , handle
     , DATE_FORMAT(insert_date,'%l:%i:%S %p') 
         [b]as display_insert_date[/b]
  FROM session 
ORDER BY insert_date


rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts July 10 2005)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top