How to Get the Current Date in MariaDB

Galaxy Glossary

How do I get the current date in MariaDB?

Returns today’s date as a DATE value without the time portion.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

What does CURRENT_DATE return?

CURRENT_DATE (or its synonym CURDATE()) returns the server’s current date as a DATE value, formatted YYYY-MM-DD, with no time component. Use it whenever you only need the date part.

How do I select today’s orders?

Filter rows where order_date = CURRENT_DATE. This isolates records created today regardless of the time zone set on the connection.

SELECT *
FROM Orders
WHERE order_date = CURRENT_DATE;

Can I store CURRENT_DATE in a column?

Yes.Set a DATE column’s default to CURRENT_DATE, or insert the function explicitly. The column records the day the row was created.

ALTER TABLE Orders
ADD COLUMN created_on DATE DEFAULT CURRENT_DATE;

Why choose CURRENT_DATE over NOW()?

NOW() returns a DATETIME. If your column type is DATE, NOW() triggers an implicit cast that can hide time-zone errors. CURRENT_DATE avoids this.

How do I use it in arithmetic?

Add or subtract integers to move days forward or back.For instance, CURRENT_DATE - 7 gets the date one week ago.

SELECT COUNT(*)
FROM Orders
WHERE order_date >= CURRENT_DATE - INTERVAL 7 DAY;

Best practices

1) Use DATE columns when you don’t need the time. 2) Match data types in predicates. 3) Index DATE columns used with CURRENT_DATE for faster lookups.

.

Why How to Get the Current Date in MariaDB is important

How to Get the Current Date in MariaDB Example Usage


-- Find customers who placed an order today
SELECT c.id, c.name, o.id AS order_id, o.total_amount
FROM Customers c
JOIN Orders o ON o.customer_id = c.id
WHERE o.order_date = CURRENT_DATE;

How to Get the Current Date in MariaDB Syntax


-- Return today’s date
SELECT CURRENT_DATE;               -- Standard SQL
SELECT CURDATE();                  -- MariaDB synonym

-- Use in expressions
SELECT CURRENT_DATE + INTERVAL 1 DAY; -- Tomorrow
SELECT CURRENT_DATE - INTERVAL 1 WEEK;-- One week ago

-- Insert default date into Orders table
INSERT INTO Orders (customer_id, order_date, total_amount)
VALUES (12, CURRENT_DATE, 199.99);

-- Set default on new column
ALTER TABLE Orders
ADD COLUMN created_on DATE DEFAULT CURRENT_DATE;

Common Mistakes

Frequently Asked Questions (FAQs)

Does CURRENT_DATE include the time?

No. It returns only the date portion. Use NOW() if you need time.

Is CURDATE() different from CURRENT_DATE?

They are synonyms. Choose whichever you find more readable.

Can I use CURRENT_DATE in CHECK constraints?

Yes, but only for column default expressions, not row-level CHECKs, because MariaDB evaluates CHECK at insertion time without built-in functions.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.