MySQL DAYOFYEAR() function
has average rating
5
out of 10.
Total 1 users rated.
Description
MySQL DAYOFYEAR() returns day of the year for a date. The return value is within the range of 1 to 366.
Syntax
DAYOFYEAR(date)
Where date is a date.
Example :
Code
SELECT DAYOFYEAR('2008-05-15');
Explanation
The above statement will return the day of year from the given date 2008-05-15.
Output
.gif)
PHP script
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>example-DAYOFYEAR-function - php mysql examples | w3resource</title>
</head>
<body>
<?php
echo "<h2>Extracting day of the year from 2008-05-15 : </h2>";
echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";
echo "<tr style='font-weight: bold;'>";
echo "<td width='250' align='center'>Day of the year from 2008-05-15</td>";
echo "</tr>";
include("../dbopen.php");
$result = mysql_query("SELECT DAYOFYEAR('2008-05-15')");
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center' width='200'>" . $row["DAYOFYEAR('2008-05-15')"] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>

