Click to See Complete Forum and Search --> : php/sql date problem


fogofogo
06-02-2006, 06:03 AM
Hi folks,

I have a form that submits a date in this format : June 2006, and I am trying to use it to select records in a mysql database, that stores the date in this format: 2006-06-01.

So I must change June 2006 into 2006-06-01 and then feed it into the feed the date into the SQL statement - right?? This is the part I am stuck on.

some thing like this?

$formattedDate = date("F Y", strtotime($month));

my code so far (which is probably way off), looks like this...

<?php

// print out the month that has been choosen

$month = $_POST['date'];
echo $month;

//$formattedDate = date("F Y", strtotime($month));

...
database stuff
...

$query = mysql_query("SELECT DISTINCT ddate, DATE_FORMAT(ddate, '%Y %M') ID FROM pokercredit");

// print out the records

while ($row = mysql_fetch_array($query)){
echo "$row[ID] $row[dfrom] $row[damount]<br>"; // name class and mark will be printed with one line break at the end
}

?>


I'm obviously way off but any advice would be great, as I'm totally stuck on this.

Thanks all

J

abou.hmed
06-02-2006, 07:07 AM
$formattedDate = date("Y-m-d", strtotime($month));

fogofogo
06-02-2006, 08:26 AM
nice one! thanks