如何在导出至Excel 2016时设置可排序的日期格式?
Absolutely! You can resolve this so Excel recognizes your exported dates as proper date values (enabling immediate sorting and filtering) using either of these two approaches:
Option 1: Adjust SQL Developer's Global NLS Date Format
This changes how date fields are displayed and exported across all your queries:
- Open SQL Developer, go to
Tools>Preferences - Navigate to
Database>NLSin the left sidebar - Locate the
Date Formatfield (currently set toDD-MON-RR) - Replace it with an Excel-friendly format like
YYYY-MM-DDorMM/DD/YYYY—these formats are universally recognized by Excel as date types - Click
OKto save your settings, then re-run your query and export again. Your dates should now work with Excel's sorting/filtering tools right away.
Option 2: Format Dates Directly in Your Query
If you don’t want to modify global settings, explicitly format your date columns in the query to output an Excel-compatible string:
SELECT your_other_columns, TO_CHAR(your_date_column, 'YYYY-MM-DD') AS export_ready_date FROM your_target_table;
This ensures the exported value is a string that Excel automatically parses into a date. The 4-digit year eliminates ambiguity that causes Excel to treat DD-MON-RR values as plain text.
Why Your Current Format Causes Problems
The DD-MON-RR format uses a 2-digit year (RR), which Excel often interprets as text instead of a date—especially if your system’s regional settings don’t match this format. Switching to a 4-digit year format removes that ambiguity, letting Excel correctly identify the values as dates.
内容的提问来源于stack exchange,提问作者bd528

