MySql MAKEDATE() function
Description
MySQL MAKEDATE() returns a date by taking a value of a year and a number of days. The number of days must be greater than 0 other wise a NULL will be returned.
Syntax
MAKEDATE(year,dayofyear);
Arguments
| Name | Description |
|---|---|
| year | Indicates a year. |
| dayofyear | An integer indicating days of year. |
Example :
Code
SELECT MAKEDATE(2009,138);
Explanation
The above statement will make a date from year 2009 and number of days 138.
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-MAKEDATE-function - php mysql examples | w3resource</title>
</head>
<body>
<?php
echo "<h2>Make a date from the year 2009 and number of days value 138 using MySQL : </h2>";
echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";
echo "<tr style='font-weight: bold;'>";
echo "<td width='100' align='center'>Date</td>";
echo "</tr>";
include("../dbopen.php");
$result = mysql_query("SELECT MAKEDATE(2009,138)");
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center' width='200'>" . $row["MAKEDATE(2009,138)"] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>

