Computer >> Computer tutorials >  >> Software >> Office

Master Power Query Date Functions in Excel: 3 Practical Examples

Consider the dataset below. Some products of an online store, their order, and delivery dates are provided.

Master Power Query Date Functions in Excel: 3 Practical Examples

Example 1 – Getting the Year, Quarter, Month, and Day

Steps:

  • Click a random cell on the data, go to the Data tab, and then click From Table/Range.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • The Create Table dialog box will come up. Click OK.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • The Power Query Editor window will show up. You will see your dataset in that window. The date has been shown with time here.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • In the Order Date column, click the icon (clock-calendar icon) at the top-left corner.
  • Select Date from the dropdown.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • You will see a new pop-up named Change Column Type. Here, click Replace Current.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • The data type will be changed to Date.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • Go to the Add Column tab in the Power Query Editor.
  • You will see the Date. This icon has the desired Date functions.
  • Click the dropdown.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • In the dropdown list of the Date icon, you will see a couple of functions like Age, Year, Quarter, Month, Week, and Day.
  • To extract the Year from your date, click the drop-right arrow of the Year option, then select Year.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • A new column has been inserted mentioning the Year from the date list (i.e. 2020 has been extracted from the date 23-Mar-20).

Master Power Query Date Functions in Excel: 3 Practical Examples

  • If you want to get in which Quarter of the concerned year your date exists, go to the Date icon and select Quarter then Quarter of Year.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • You will see the Quarter column beside the Year.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • Repeat the process for extracting the Month.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • You will get the Month column added beside the previous column.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • Similarly, get the Day from the date.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • Go to the Home tab of the Power Query window and click Close & Load.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • This command will load the data to the Excel worksheet window.

Master Power Query Date Functions in Excel: 3 Practical Examples

Example 2 – Finding the Differences Between Two Dates

Consider this dataset. We want to find the difference between the order date and the delivery date.

Master Power Query Date Functions in Excel: 3 Practical Examples

Steps:

  • Import the data to the Power Query Editor window following the same steps as Method 1.
  • Select the Order Date column and Delivery Date column together by holding the Ctrl key.
  • Go to the Add Column tab and click the dropdown of the Date icon, then select Subtract Days.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • A new column named Subtraction has been inserted calculating the difference between the two dates.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • Apply the Close & Load command to load this data to the Excel worksheet.

Master Power Query Date Functions in Excel: 3 Practical Examples

Example 3 – Getting the Name of the Day and the Month

Steps:

  • Import the data to the Power Query window.
  • Go to Add Column.
  • Click the drop-down for Date.
  • Select Day and click Name of Day.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • The Name of the corresponding Date has been inserted beside the Date.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • Similarly, find the Month name and add a new column named Month Name.

Master Power Query Date Functions in Excel: 3 Practical Examples

  • Load the data to the Excel window and you’re done.

Master Power Query Date Functions in Excel: 3 Practical Examples

Practice Section

We’re providing you with a practice sheet so that you can practice yourself. Try to find out anything you want by applying the Power Query Date functions.

Master Power Query Date Functions in Excel: 3 Practical Examples

Download the Practice Workbook

<< Go Back to Power Query Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!