×

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 Data Types

Introduction of the Data types In the data file, we have several information such as names, numbers, marks, and other information. This information specifies categories such as numbers, characters, and decimal...

8 minutes read.

MySQL Full text index

Full text index The full-text index in the table isused to search the full text of the data. This index assigns to the table using a "FULLTEXT" keyword. First, the table...

3 minutes read.

MySQL POW() function

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

2 minutes read.

MySQL INSERT() Function

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

2 minutes read.

MySQL ELT() function

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

2 minutes read.

MySQL IF statement

The IF statement shows the true condition of the control flow function. The first condition is necessary to fulfill the requirement. The other condition is optional in the "IF" statement....

3 minutes read.

MySQL Composite Index

Composite Index A composite index is an index that is used on multiple columns. MySQL management system manages multiple columns simultaneously. Therefore, the single index contains multiple columns in one query...

3 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 Table

Introduction MySQL table is an essential part of the system. MySQL table stores data using index, rows, and columns. It accesses data from the server quickly because of the table—this table...

22 minutes read.

MySQL EXPORT_SET() function

In this context, we will learn how we can use the MySQL EXPORT_SET() function with proper syntax and good examples. Introduction of MySQL EXPORT_SET() function This function returns a string and shows...

3 minutes read.

find_in_set() function in MySQL

This Function is used for finding the position of a particular string from the list of strings. For suppose if the specified string is repeated multiple times, then this functions...

4 minutes read.

MySQL Date and Time function

The date function displays day, year, month, time, and current date. It shows the date and time as per the requirement of the applications. The data either store on the...

8 minutes read.

MySQL TAN() Function

Basically, the TAN() function in MySQL is used to give back the tangent of a mentioned number.In any kind of right-angle triangle, the tangent of an angle is the length...

2 minutes read.

MySQL LOAD_FILE() function

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

3 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 LOCATE() function

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

3 minutes read.

MySQL PI() function

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

2 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 LN() function

In this context, we will learn how we can use the MySQL LN() function with proper syntax and good examples. Introduction of MySQL LN() function For evaluation of the natural logarithm of...

2 minutes read.