Jump to content

[SOLVED] Date Format in Join Statement?


Petty_Crim

Recommended Posts

$get_matches=mysql_query("SELECT matches.match_id, matches.game, matches.opponent, matches.map, DATE_FORMAT(`matches.date`, '%d/%c/%y') AS 'matches.date', matches.time, players.player_id, players.match_id FROM matches, players WHERE matches.match_id = players.match_id AND players.player_id='$player_id' AND matches.game='$game'") OR die(' ERROR GETTING TOTAL $game MATCHES ' . mysql_error());

 

Basically I'm trying to format a date column from the american style date format into the european one, but for some reason its not working. I've got it working in non join statements but I don't know how to do it in a join statement.

Link to comment
https://forums.phpfreaks.com/topic/65447-solved-date-format-in-join-statement/
Share on other sites

$get_matches=mysql_query("SELECT matches.match_id, matches.game, matches.opponent, matches.map, DATE_FORMAT(`matches.date`, '%d/%c/%y') AS 'matches.date', matches.time, players.player_id, players.match_id FROM matches, players WHERE matches.match_id = players.match_id AND players.player_id='$player_id' AND matches.game='$game'") OR die(' ERROR GETTING TOTAL $game MATCHES ' . mysql_error());

 

Basically I'm trying to format a date column from the american style date format into the european one, but for some reason its not working. I've got it working in non join statements but I don't know how to do it in a join statement.

 

try ur query like this:

 

$get_matches=mysql_query("SELECT matches.match_id, matches.game, matches.opponent, matches.map,DATE_FORMAT(`matches.date`, '%d/%c/%y') AS formatted_date, matches.time, players.player_id, players.match_id FROM matches, players WHERE matches.match_id = players.match_id AND players.player_id='$player_id' AND matches.game='$game'") OR die(' ERROR GETTING TOTAL $game MATCHES ' . mysql_error()); 

 

Thx for the help but neither of those two methods worked. After testing a few different things I just did:

 

$get_matches=mysql_query("SELECT matches.match_id, matches.game, matches.opponent, matches.map, DATE_FORMAT(`date`, '%d/%c/%y') AS 'date', matches.time, players.player_id, players.match_id FROM matches, players WHERE matches.match_id = players.match_id AND players.player_id='$player_id' AND matches.game='$game'") OR die(' ERROR GETTING TOTAL $game MATCHES ' . mysql_error());

 

This worked and for some reason I didn't have to refer to the table ie matches.date if I did that it wouldn't work but just the field by itself does.

 

Archived

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

×
×
  • Create New...

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.