Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Datetime Format: How to Customize Date and Time

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To format a datetime in Excel, select your cells, right-click and choose Format Cells, then select Date or Time from the Category list, or enter a custom code in the Custom category. This process allows you to transform raw numerical data into readable dates and timestamps, ensuring your spreadsheets are professional and easy to analyze.

What You'll Need

  • A computer with Microsoft Excel installed (Windows or macOS).
  • A dataset containing dates, times, or numerical values that represent dates.
  • Basic familiarity with selecting cells and using the ribbon menu.

Step-by-Step

  1. Select Your Data: Click on a single cell, click and drag to select a range, or click the column letter (e.g., Column A) to select the entire column. Formatting is applied to whatever is currently highlighted.
  2. Open the Format Cells Dialog: There are three ways to do this. You can right-click the selected cells and choose Format Cells... from the context menu. Alternatively, you can use the keyboard shortcut Ctrl + 1 (Windows) or Command + 1 (Mac). You can also go to the Home tab on the ribbon, find the Number group, and click the small arrow icon in the bottom-right corner of that group. Note that menu labels may differ slightly depending on your version of Excel or region.
  3. Choose a Preset Category: In the Format Cells window, ensure you are on the Number tab. In the Category list on the left, you will see options for Date and Time.
  4. Select a Preset Format: If you choose Date, a list of formats will appear on the right (e.g., 3/14/12, March 14, 2012, or 14-Mar-12). Click the one that best fits your needs. If you choose Time, you can select formats that include seconds or AM/PM indicators.
  5. Create a Custom Format: For more control, select Custom from the Category list. In the Type field, you can manually enter a code to define exactly how the date and time appear. For example, typing yyyy-mm-dd hh:mm will display a date as 2023-10-25 14:30.
  6. Apply and Confirm: Once you have selected or typed your desired format, click OK. Your data will now reflect the chosen visual style without changing the underlying value of the cell.

Common Mistakes

One of the most frequent errors is confusing the visual format with the actual data stored in the cell. In Excel, dates are actually stored as sequential serial numbers (where January 1, 1900, is number 1). If you see a random five-digit number like 45210, it doesn't mean your data is corrupted; it simply means the cell is formatted as General or Number instead of Date. Changing the format fixes the display but does not change the number.

Another common mistake is using the wrong case for custom codes. In Excel custom formatting, m stands for month, but it also stands for minute. Excel determines which one you mean based on the context. If m follows an hour code (h:mm), Excel treats it as minutes. If it stands alone or follows a year code (yyyy-mm-dd), Excel treats it as the month. Forgetting this distinction can lead to timestamps that show the month where the minutes should be.

Users also frequently try to "fix" dates by typing them as text. If you type a date as "October 25th, 2023" manually, Excel may treat it as a text string rather than a date value. This means you cannot use that cell in calculations, such as subtracting one date from another to find the number of days elapsed. Always enter dates in a format Excel recognizes (like 10/25/2023) and use the Format Cells menu to change how it looks.

Tips

To speed up your workflow, use the Format Painter. Once you have perfectly formatted one cell with a complex custom datetime string, click that cell, click the Format Painter icon (the paintbrush) on the Home tab, and then click or drag over other cells to apply the same formatting instantly.

When building custom formats, remember these specific codes for maximum precision:

  • d: Day as a single digit (1).
  • dd: Day as two digits (01).
  • ddd: Short day name (Mon).
  • dddd: Full day name (Monday).
  • m: Month as a single digit (1).
  • mm: Month as two digits (01).
  • mmm: Short month name (Jan).
  • mmmm: Full month name (January).
  • yy: Two-digit year (23).
  • yyyy: Four-digit year (2023).
  • h: Hour (0-23).
  • mm: Minutes (00-59).
  • ss: Seconds (00-59).

If you need to enter the current date or time quickly before formatting, use keyboard shortcuts. Press Ctrl + ; (semicolon) to insert the current date, and press Ctrl + Shift + : (colon) to insert the current time. These are static entries, meaning they will not change when the workbook is reopened tomorrow.

Troubleshooting

If you change the format to Date or Time but the cell still shows a number or a text string, the data may be stored as text. This often happens when importing data from CSV files or other software. To fix this, you can use the Text to Columns feature. Select the column, go to the Data tab, click Text to Columns, click Next twice to reach Step 3, select Date, choose the format the data is currently in (e.g., MDY), and click Finish. This forces Excel to re-evaluate the text as a numerical date.

If you see a series of hash symbols (#######) after applying a datetime format, it does not mean there is an error in your formula. It simply means the column is too narrow to display the full date or time string. To resolve this, double-click the boundary line between the column headers at the top of the sheet to automatically resize the column to fit the content.

If your dates are appearing in the wrong order (e.g., Day/Month/Year instead of Month/Day/Year), this is usually a result of your computer's regional settings rather than an Excel setting. Excel defaults to the system locale. To override this for a specific project, avoid the "Short Date" preset and instead use the Custom category to explicitly define the order using mm/dd/yyyy or dd/mm/yyyy.

Frequently Asked Questions

How do I show only the time in a cell that has both date and time?

Select the cell, open Format Cells, go to Custom, and enter a time-only code such as hh:mm AM/PM. The date is still stored in the cell, but it is hidden from view.

Can I format a date to show the full name of the day?

Yes. In the Custom format field, use the code dddd. For example, dddd, mmmm dd, yyyy will display as "Wednesday, October 25, 2023".

Why does my date turn into a number when I change the format?

Excel stores dates as numbers (the number of days since Jan 1, 1900). If the format is set to General or Number, you see the raw value. Change it back to Date to see the calendar format.

How do I format a cell to show milliseconds?

In the Custom format category, use the code hh:mm:ss.000. The .000 tells Excel to display three decimal places for the seconds, representing milliseconds.

Is there a way to make dates automatically update to today's date?

Formatting only changes how a value looks. To make a date update automatically, use the formula =TODAY() for the date or =NOW() for both date and time. You can then apply any datetime format to these formula cells.