MAKEDATE() : Date from year and day number

SELECT MAKEDATE(2023,5); # 2023-01-05
SELECT MAKEDATE(2023,365); # 2023-12-31
SELECT MAKEDATE(2024,365); #2024-12-30
SELECT MAKEDATE(2024,369); # 2025-01-03
Returns date by using day number ( of a year ) and year.
Syntax
MAKEDATE(year,dayofyear)
Example :
SELECT MAKEDATE(2016,34) 
Output is 2016-02-03

Read more to know What is dayofyear

CURDATE() YEAR()

By using CURDATE() we get the present date part, by using YEAR() we will get YEAR. Here is a query with all these functions.
SELECT MAKEDATE(YEAR(CURDATE()),DAYOFYEAR(CURDATE()))
Output is 2024-03-18

PHP Script

To display the above details we used PHP Script, you can use the same script for using all above queries.

config.php connection string is available here

PDO for executing Queries in PHP

How to get records using FETCH() are here

<?Php
require 'config.php';  // Database connection string
$query='SELECT MAKEDATE(YEAR(CURDATE()),DAYOFYEAR(CURDATE()) )as dt';
// Change the above Query part to get different results // 

$count=$dbo->prepare($query);
$count->execute();
$row = $count->fetch(PDO::FETCH_OBJ);
echo 'Output is : '.$row->dt; 
?>

DATEOFYEAR() : Number of day in a year

SQL Date References MONTH() DAY() NOW() : Current Date with Time
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com

    Post your comments , suggestion , error , requirements etc here





    SQL Video Tutorials










    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer