Forum Moderators: coopster
how can i find out what weekday this date falls on?
// Get the Formatted DATE for the invoice number from the orders table
$query = "SELECT DATE_FORMAT(invoiceDate, '0,0,0,%m,%d,%Y') FROM orders WHERE invoiceNumber=" . $invoiceNumber;
$resultDate = @mysql_query($query);
$rowDate = mysql_fetch_array($resultDate);
$formatedDate = $rowDate["DATE_FORMAT(invoiceDate, '0,0,0,%m,%d,%Y')"];
echo "<br>formatedDate = " . $formatedDate; //** this line prints - formatedDate = 0,0,0,07,15,2002
//$datestamp=mktime(0,0,0,07,15,2002); //** when i use this line i get the correct output , monday
$datestamp=mktime($formatedDate); //** when i use this line i get tuesday
echo "<br>datestamp= " . $datestamp;
$date = getdate($datestamp);
echo "<br>date = " . $date;
$dayofweek = $date["weekday"];
echo "<br>" . $dayofweek;
that one works great.
DAYOFWEEK [mysql.com]