Detailed Example of MySQL curdate() Function

Detailed Example of MySQL curdate() Function

MySQL CURDATE Function Introduction

If used in a string context or the YYYMMDD format in a numeric context, the CURDATE() function returns the current date as a value in the "YYYY-MM-DD" format.

The following example shows how to use the CURDATE() function in a string context.

sql> SELECT CURDATE();
+------------+
| CURDATE() |
+------------+
| 2017-08-10 |
+------------+
1 row in set (0.00 sec)

The following example shows how the CURDATE() function is used in a numeric context:

mysql> SELECT CURDATE() + 0;
+---------------+
| CURDATE() + 0 |
+---------------+
| 20170810 |
+---------------+
1 row in set

CURRENT_DATE and CURRENT_DATE() are synonyms for CURDATE().

mysql> SELECT CURRENT_DATE(), CURRENT_DATE, CURDATE();
+----------------+--------------+------------+
| CURRENT_DATE() | CURRENT_DATE | CURDATE() |
+----------------+--------------+------------+
| 2017-08-10 | 2017-08-10 | 2017-08-10 |
+----------------+--------------+------------+
1 row in set

CURDATE and NOW Functions

The CURDATE() function returns only the current date, whereas the NOW() function returns both the date and time portion of the current time. The result of the CURDATE() function is equivalent to the following expression:

 
mysql> SELECT DATE(NOW());
+-------------+
| DATE(NOW()) |
+-------------+
| 2017-08-10 |
+-------------+
1 row in set

In this tutorial, you have learned how to use the MySQL CURDATE() function to get the current date value.

If you have any questions, please leave a message or come to the community of this site to communicate and discuss. Thank you for reading and I hope this can be helpful to everyone. Thank you for your support of this site!

You may also be interested in:
  • Sequence implementation method based on MySQL
  • How to install the mysqldb module in python under windows
  • Detailed steps to configure Apache + PHP + MySQL operating environment in Mac OS X
  • MySQL 5.7 installation-free configuration graphic tutorial
  • Linux implements automatic and scheduled backup of MySQL database every day
  • Detailed explanation of the implementation process of dual-master synchronization of partial tables in MySQL 5.7
  • Batch files for stopping and starting oracle and mysql databases
  • Using PHP to access the MySql database logical operations and examples of adding, deleting, modifying and checking

<<:  Detailed explanation of the use of Refs in React's three major attributes

>>:  Explanation of the steps for Tomcat to support https access

Recommend

Complete list of CentOS7 firewall operation commands

Table of contents Install: 1. Basic use of firewa...

Implementation of Docker data volume operations

Getting Started with Data Volumes In the previous...

How to run nginx in Docker and mount the local directory into the image

1 Pull the image from hup docker pull nginx 2 Cre...

HTML+CSS+JavaScript to achieve list loop scrolling example code

Description: Set a timer to replace the content of...

HTML+Sass implements HambergurMenu (hamburger menu)

A few days ago, I watched a video of a foreign gu...

MySQL Index Detailed Explanation

Table of contents 1. Index Basics 1.1 Introductio...

A Brief Discussion on the Navigation Window in Iframe Web Pages

A Brief Discussion on the Navigation Window in If...

Complete steps to reset the root user password in mysql8

Preface Recently, many new colleagues have asked ...

An article to understand what is MySQL Index Pushdown (ICP)

Table of contents 1. Introduction 2. Principle II...

jQuery implements navigation bar effect with expansion animation

I designed and customized a navigation bar with a...

Implementation of mysql decimal data type conversion

Recently, I encountered a database with the follo...

MySQL configuration SSL master-slave replication

MySQL5.6 How to create SSL files Official documen...