Convert Date from DD-Mon-YY to dd.mm.yy

Abstract: Resolve SQL date format conversion errors when transforming DD-Mon-YY strings to dd.mm.yy in MySQL and PostgreSQL.

Created: 2026-09-28 by
To convert a date from the DD-Mon-YY format to dd.mm.yy in SQL, you must parse the string into a proper date object and then reformat it. In MySQL, use STR_TO_DATE() to parse the input and DATE_FORMAT() to output the target style. For PostgreSQL, utilize TO_DATE() for parsing and TO_CHAR() for formatting, ensuring you handle the two-digit year ambiguity correctly during the conversion process.

Understanding Date Format Conversion

Date manipulation is a common requirement in data engineering and application development. The source format DD-Mon-YY typically represents a day (two digits), a three-letter month abbreviation (like Jan, Feb), and a two-digit year. The target format dd.mm.yy requires a numeric day, a dot separator, a numeric month, another dot, and a two-digit year. This transformation is not merely cosmetic; it often prepares data for systems that require strict ISO-like or localized date standards for sorting, indexing, or display. When working with SQL databases, dates are rarely stored as strings unless they are legacy fields or imported data. If your column is already a DATE or TIMESTAMP type, no conversion is needed for storage, but you may still need to format it for output. However, if the data is stored as a VARCHAR or TEXT field containing values like "01-Jan-23", you must explicitly instruct the database engine to interpret these characters. The core challenge lies in mapping the textual month name to its numeric equivalent and handling the century for two-digit years.

MySQL Implementation

MySQL provides robust functions for this specific task using STR_TO_DATE() and DATE_FORMAT(). The first function converts the string into an internal date representation, while the second formats that internal value back into a string. Consider a table named orders with a column order_date_str containing values like "15-Dec-99". To convert this, you chain the functions together. The STR_TO_DATE function takes the string and a format specifier. The specifier %d-%b-%y tells MySQL to expect a two-digit day, a dash, a abbreviated month name, another dash, and a two-digit year.
SELECT 
  DATE_FORMAT(
    STR_TO_DATE(order_date_str, '%d-%b-%y'), 
    '%d.%m.%y'
  ) AS converted_date
FROM orders;
The output of DATE_FORMAT uses %d for the day, %m for the zero-padded month number, and %y for the two-digit year. Note that %M would give the full month name, which is incorrect for our target. This approach ensures that "Jan" becomes "01", "Feb" becomes "02", and so on. For updating the actual table data rather than just selecting it, you can use an UPDATE statement. Be cautious when updating large tables, as this operation can be resource-intensive. Always test on a subset of data first.
UPDATE orders
SET order_date_str = DATE_FORMAT(
  STR_TO_DATE(order_date_str, '%d-%b-%y'), 
  '%d.%m.%y'
)
WHERE order_date_str IS NOT NULL;
This method is reliable because MySQL handles the locale-independent parsing of standard English month abbreviations by default. If your data contains non-English month names, you may need to adjust the session language or use custom mapping logic.

PostgreSQL Implementation

PostgreSQL approaches date conversion with TO_DATE() and TO_CHAR(). Similar to MySQL, these functions separate the parsing and formatting stages. The syntax is slightly different, requiring explicit casting in some contexts if the result type needs to be enforced. Assuming a table transactions with a text column trans_date, the query looks like this:
SELECT 
  TO_CHAR(
    TO_DATE(trans_date, 'DD-Mon-YY'), 
    'DD.MM.YY'
  ) AS formatted_date
FROM transactions;
In TO_DATE, the format mask 'DD-Mon-YY' is case-sensitive for the month part in some versions, but generally accepts standard abbreviations. The 'Mon' specifier matches "Jan", "Feb", etc. The output mask 'DD.MM.YY' produces the desired dot-separated numeric format. One critical difference in PostgreSQL is how it handles two-digit years. By default, PostgreSQL interprets two-digit years according to the "2020 cutoff" rule. Years 00-49 are treated as 2000-2049, and 50-99 as 1950-1999. This behavior is controlled by the datestyle configuration parameter. If your business logic requires a different cutoff (e.g., 1970), you should verify or set this parameter in your session or database configuration. If you need to store the result back into a date column, you might cast the result:
UPDATE transactions
SET trans_date = TO_DATE(trans_date, 'DD-Mon-YY')::DATE;
However, since the target format dd.mm.yy is a string representation, keeping it as text is appropriate if the downstream system expects that exact visual format. If you convert it to a DATE type, the dots will disappear, as dates do not have a fixed string format internally.

Handling Edge Cases and Errors

Data quality issues often arise during conversion. Invalid month names, such as "Xyz", will cause the conversion functions to return NULL or raise an error, depending on the database settings. It is prudent to filter out bad records before attempting conversion. You can use conditional logic to identify rows where the conversion fails. In MySQL, you can check if STR_TO_DATE returns NULL. In PostgreSQL, similar checks apply. Cleaning the data beforehand prevents silent failures where valid-looking dates are lost due to minor typos. Additionally, ensure that the source data consistently uses dashes (-) as separators. If some records use slashes (/) or spaces, you may need to preprocess the string using REPLACE() or regular expressions before applying the date conversion functions. Linux Bash: Convert Date-Time Formats with Ease provides complementary techniques for handling these transformations at the operating system level, which can be useful for preprocessing files before database import. Similarly, understanding how to manipulate date outputs in Linux environments can help automate the cleaning pipeline.

Frequently Asked Questions

What happens if the month abbreviation is in a different language?

Standard SQL functions rely on the server's locale settings for month names. If your data uses Spanish or French months, you must either change the session locale or manually map the names using CASE statements before conversion.

Can I convert the date directly without parsing it first?

No, SQL engines cannot guess the structure of a string. You must explicitly define the input format using the parser function (STR_TO_DATE or TO_DATE) to establish the correct internal date object.

How does PostgreSQL handle years between 1950 and 2049?

PostgreSQL uses a 50-year cutoff by default. Years 00-49 become 2000-2049, while 50-99 become 1950-1999. You can adjust this behavior via the datestyle setting if your historical data requires a different interpretation.

Why did my date turn into NULL after conversion?

NULL usually indicates a mismatch between the input string and the format mask. Check for extra spaces, incorrect separators (like slashes instead of dashes), or invalid month names that do not match the expected abbreviations.

Is it better to store dates as strings or date types?

It is always better to store dates as DATE or TIMESTAMP types for efficient querying and sorting. Use string conversion only for display purposes or when dealing with legacy data that must be cleaned before migration.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More