×

MySQL CURRENT_DATE() Function

In this context, we will learn how we can use the MySQL CURRENT_DATE() function to get the current date, and we will see in the two formats, such as strings and numeric, respectively.

Introduction of MySQL CURRENT_DATE()function:

We will see in this function how we can use the current date function. In this, there are two formats for getting the current date by this function, such as “ YYYY – MM – DD”, which is in string format or YYYYMMDD, which is in numeric format.

Syntax of CURRENT_DATE() function in MySQL

CURRENT_DATE()

Parameter used in CURRENT_DATE()function

There is no parameter accepted by this method.

Returns:

The current date is returned in this.

Important points of MySQL CURRENT_DATE() function:

  • If we are using the string format, then we will get the current date as a ‘ YYYY – MM – DD’ from the CURRENT_DATE() function.
  • On the other hand, if we are using the numeric context, then we will get the current date as a YYYYMMDD from the CURRENT _DATE function.
  • The CURRENT_DATE()function is a synonym for the CUR_DATE function.

Application used for CURRENT_DATE() function:

The CURRENT_DATE()function is used in the given below MySQL versions.

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1
  • MySQL 4.0
  • MySQL 3.23

Example:

Describe the method in which the CURRENT_DATE() () function is used in the context of the string to get the current date.

SELECT CURRENT_DATE() AS CURR_DATE ;

Output:

CURR_DATE
2019 – 08 – 17
1 row in set (0.00 sec)

Example:

Write the method in which the CURRENT_DATE() function is used to find the present date in YYYYMMDD format, which is the numeric format.

SELECT CURRENT_DATE() + 0 AS CURR_DATE ;

Output:

CURR_DATE
20190817
1 row in set (0.00 sec)
/

Example:

In this example, we will see how we can get the next 5 days' date by the CURRENT_DATE() function in the YYYYMMDD format.

SELECT CURRENT_DATE() +5 AS NEXT_DATE ;

Output:

NEXT _DATE
20190822
1 row in set (0.00 sec)

Example:

This example shows how we can get the date 6 days before the current date in the format of YYYYMMDD, which is a numeric context.

SELECT CURRENT_DATE() – 6 AS PREV_DATE ;

Output:

PREV_DATE
20190810
1 row in set (0.00 sec)

Application of MySQL CURRENT_DATE()function:

This function is used to get the current date in MySQL in two formats.

Summary:

In the above context, we have learned how we can use the CURRENT_DATE() function in MySQL used to get the current date in MySQL in two formats.


Related Topics

MySQL Tutorial

In this tutorial, you will get information about the MySQL management system. This tutorial will cover the basic and advanced level MySQL concepts with examples that will help you become...

5 minutes read.

MySQL DAY() function

In this context, we will learn how we can use the MySQL DAY() function with proper syntax and good examples. Introduction of MySQL DAY() function This function in MySQL is used to...

2 minutes read.

MySQL SUM function

The SUM() function displays the total addition of the table values. It supports the arithmetic operation of the column values. This function does not return a null value. Here, the...

5 minutes read.

MySQL ROUND() function

In this context, we will learn how we can use the MySQL ROUND() function with proper syntax and good examples. Introduction of MySQL ROUND() function The ROUND() function in MySQL is used...

3 minutes read.

MySQL vs Oracle

What is MySQL? The open-source MySQL relational database management system is a vital software component for web-based applications. As the data is saved and sent over the internet, databases and related...

6 minutes read.

MySQL database queries

MySQL database queries Database queries help to create, use, show and, delete the database. A Database is a collection of several tables and data. The database uses SQL language to perform...

3 minutes read.

MySQL LIKE() function

In this context, we will learn how we can use the MySQL LIKE() function with proper syntax and good examples. Introduction of MySQL LIKE() function The LIKE function is a logical function...

4 minutes read.

MySQL LEAST function

This statement displays the smallest value of the table. The LEAST function returns a null value when the table contains a null value. If the table contains all numerical values,...

2 minutes read.

MySQL QUARTER() function

In this context, we will learn how we can use the MySQL QUARTER() function with proper syntax and good examples. Introduction of MySQL QUARTER() function The QUARTER() function in MySQL returns the...

3 minutes read.

MySQL FROM_BASE64() function

In this context, we will learn how we can use the MySQL FROM_BASE64()() function with proper syntax and good examples. Introduction of MySQL FROM_BASE64()() function Basically, the FROM_BASE64() function In MySQL decodes...

2 minutes read.

MySQL HEX() function

In this context, we will learn how we can use the MySQL HEX() function with proper syntax and good examples. Introduction of MySQL HEX() function For returning an equivalent hexadecimal string value...

3 minutes read.

MySQL RIGHT JOIN

MySQL right join links two tables with each other. The left table column connects with the complete right side table. Each row of the right table tries to connect with...

4 minutes read.

MySQL LOG10() function

In this context, we will learn how we can use the MySQL LOG10() function with proper syntax and good examples. Introduction of MySQL LOG10() function To evaluate the natural logarithmic value of...

2 minutes read.

MySQL Command line client Basic Queries

MySQL – command line client Basic Queries There are many queries to work with the MySQL command-line client. Today, we will explore MySQL basic queries and their function. The MySQL query...

8 minutes read.

MySQL Control flow function

The control flow function uses values or operands for logical operations. These functions can works on single and multiple conditions. The control flow function is based on the Boolean expression....

3 minutes read.

MySQL Vs MongoDB

What is MongoDB? MongoDB is a distributed, open-source, cross-platform document-based database which was created to scale and develop applications simply. It was created as a NoSQL database by MongoDB Inc. MongoDB gets...

6 minutes read.

MySQL Prefix index

Prefix index This index query creates an index column in the string or character column. MySQL system can create multiple indexes in the table. It will create in a table as...

3 minutes read.

MySQL COALESCE function

This statement displays the first non-null value of the table data. The COALESCE function returns a null value when all values of the table are null or do not find...

3 minutes read.

MySQL Features

Features of MySQL MySQL is a relational database management system (RDBMS): It is a collection of many programs and makes relations with many other programs. Easy to use MySQL database: MySQL...

2 minutes read.

MySQL REVERSE() function

In this context, we will learn how we can use the MySQL REVERSE() function with proper syntax and good examples. Introduction of MySQL REVERSE() function This function could be used to reverse...

2 minutes read.