Beginner

120. Date Formatting

Learn how SQL can format date and time values for reporting and presentation.

📘 Lesson 120 of 728 ⏱ 9 min 🎯 Beginner

Date formatting converts a date or timestamp into a desired text representation, such as DD-MM-YYYY, YYYY-MM-DD, or a month name. Formatting functions vary significantly between database systems.

Raw date values may not always be displayed in the format required by a business report. Formatting helps present dates in a readable and consistent way.

A report may need to display an order date as 08-Aug-2026 instead of the database's default date representation.

SQL
SELECT
    OrderDate,
    TO_CHAR(OrderDate, 'DD-Mon-YYYY') AS FormattedDate
FROM Orders;

Date formatting is commonly used in dashboards, reports, exports, invoices, customer communications, and management summaries.

  • Date formatting changes presentation.
  • Formatting does not necessarily change the stored date.
  • Different databases use different formatting functions.
  • Formatted dates are often returned as text.
  • Keep dates as date types when calculations are required.
What is date formatting?

Date formatting converts a date or timestamp into a desired display representation.

Does date formatting usually change the stored date?

No. Formatting normally changes how the date is displayed or returned, not the underlying stored value.

Have you finished this lesson?

Introduction to SQL – All Lessons