Excel uses a variety of codes to format dates and times. These codes can be used to control the display of days, months, years, hours, minutes, and seconds. By default, Excel displays dates in the "mm/dd/yy" format and times in the "h:mm AM/PM" format. However, you can change these formats to suit your needs.
To understand how date and time formatting codes work in Excel, let's take a look at an example:
The code "mm/dd/yy" is a code for formatting dates. The "m" stands for month, the "d" stands for day, and the "y" stands for year. The "/" character is used as a separator between the different parts of the code. So, if we wanted to format a date as "January 1st, 2020", we would use the code "01/01/20".
The code "h:mm AM/PM" is a code for formatting times. The "h" stands for hour, the "mm" stands for minutes, and the "AM/PM" part indicates whether the time is in the morning or evening. The ":" character is used as a separator between the different parts of the code. So, if we wanted to format a time as "9:00 AM", we would use the code "9:00 AM".
Now that we know how date and time formatting codes work in Excel, let's take a look at how we can use them to format cells in our worksheets.
To format a cell as a date, select the cell and then click on the Format Cells button in the Number group on the Home tab of the ribbon. This will open the Format Cells dialog box.In the Category list on the left side of the dialog box, select Date. This will display a variety of date formats that you can choose from. Select the desired format and then click on the OK button. The selected format will be applied to the selected cell (or cells).