Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

MySQL MAKEDATE Function

by suresh

MySQL MAKEDATE function is a Date Function, which is used to return or get date from year and day of year given by us.

In this article, we will show you, How to use this MySQL Make Date function to get date with an example.

MySQL Makedate Syntax

The basic syntax of the Makedate() Function in MySQL is as shown below:

MAKEDATE(year, day-of-year);

MySQL Makedate function Example

These examples helps you understand the use of this MySQL Makedate function. Here, we are trying to return or get date based on the year and day of year.

SELECT MAKEDATE(2017, 25);

SELECT MAKEDATE(2017, 32);

SELECT MAKEDATE(2017, 185);

OUTPUT

MySQL MAKEDATE Function 1

Let us see another example of MySQL Makedate function. Here, we are trying to return date from day of number greater than 366

When you specify the day of number more than 365, 366 (Leap) then it will increment the year.

SELECT MAKEDATE(2017, 365), MAKEDATE(2017, 366);

SELECT MAKEDATE(2017, 765), MAKEDATE(2017, 1366);

OUTPUT

MySQL MAKEDATE Function 2

MySQL MAKEDATE Function Example 2

The following queries show you, what happens when we try to return the date from 0 year or 0 day of year.

SELECT MAKEDATE(YEAR(NOW()), DAYOFYEAR(NOW()));

SELECT MAKEDATE(2019, 0);

SELECT MAKEDATE(0000, 30);

OUTPUT

MySQL MAKEDATE Function 3

From the above screenshot, First, we used the YEAR, DAYOFYEAR, and NOW functions inside this MAKEDATE. This might helps you to understand, how we can use other date functions inside MAKEDATE function.

Within the Next statement, we used 0 as day of number. That’s why it has retuned NULL.

Thank You for Visiting Our Blog

Placed Under: MySQL

Trending Posts

Java codePointCount Method

Python Assignment Operators

Java Program to Print Box Number Pattern of 1 and 0

Select Rows with Maximum Value on a Column in SQL Server

Format Power BI Ribbon Chart

C Program to Replace All Occurrence of a Character in a String

Create Dimension in SSAS

C Program to Find Nth Fibonacci Number

Grouped Bar Chart in Tableau

Python Program to find Prime Factors of a Number

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy