Hi!
I've got 3 var ($year, $month and $day) and i want to put this in a date field into the db.
I know that it's not the best to use this method but the client need it that way.
How can i convert these 3 var and put it into the date field?
n
if using a standard mysql DATE column and if $year=2004 and $month = 06 and $day= 23
$query=" INSERT INTO mytable SET mydate='$year$month$day' "; mysql_query($query);
PS: Using a DATE column is a GOOD THING...
I'm using a standard Date column and my 3 vars are exactly the same as yours... but the Date column still 0000-00-00??
make sure you put in Quotes
I usually compile my date before it goes to the database like
$date=$year."-".$month."-".$day
and then just insert the $date value. and I agree with nemonoman - DATE fields are a VERY good thing. 🙂
thank to all... it's working that way: $date=$year."-".$month."-".$day