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

CentOS8 installation tutorial of jdk8 / java8 (recommended)

Preface At first, I wanted to use wget to downloa...

WeChat applet implements user login module server construction

I chose node.js to build the server. Friends who ...

Some pitfalls of JavaScript deep copy

Preface When I went to an interview at a company ...

PHP scheduled backup MySQL and mysqldump syntax parameters detailed

First, let's introduce several common operati...

Detailed explanation of virtual DOM and diff algorithm in react

The role of virtual DOM First of all, we need to ...

Vue3 implements Message component example

Table of contents Component Design Defining the f...

MySQL 5.7 zip archive version installation tutorial

This article shares the installation tutorial of ...

WML tag summary

Structure related tags ---------------------------...

JS implements simple calendar effect

This article shares the specific code of JS to ac...

How to move a red rectangle with the mouse in Linux character terminal

Everything is a file! UNIX has already said it. E...

Install .NET 6.0 in CentOS system using cloud server

.NET SDK Download Link https://dotnet.microsoft.c...

How to build a MySQL high-availability and high-performance cluster

Table of contents What is MySQL NDB Cluster Preli...

Pure CSS3 code to implement a running clock

Operation effectCode Implementation html <div ...

Writing daily automatic backup of MySQL database using mysqldump in Centos7

1. Requirements: Database backup is particularly ...

My personal summary of mysql 5.7 database installation steps

1.mysql-5.7.19-winx64.zip (this is the free insta...