Last time, I shared some useful tools for handling date and time data. But Minitab has many other useful tools for manipulating date/time data that you might not be aware of. Let’s take a look at a few more helpful tips and tricks.
Extracting Information from a Date/Time Column
If you look under the Data menu, you’ll notice Extract from Date/Time > To Numeric or To Text. This function allows you to take one or multiple components that make up your date/time values and transform it into a new data format.
The table below illustrates the conversion that takes place when you select Quarter and Year using both extraction methods, To Numeric and To Text:
Original Value |
To Numeric |
To Text |
4/30/2012 |
20122 |
Q22012 |
After extracting to a text column, you might want to separate “Q2” and “2012” with a space. This will require that we use the Calculator, located under the Calc Menu. Under the expression box, type:
concatenate((LEFT(c3,2)), " ", (right(c3,4)))
(The expression above assumes that C3 is the column that contains your Text extraction.)
The Calculator, Subset Worksheet and Date/Time Data
I have spoken with customers who became frustrated when trying to subset a worksheet or craft an IF statement using a specific date or time. The best way to tackle this is by using one of Minitab's date/time functions:
Date/Time
- Current time
- Date
- Elapsed Time
- Net Workdays
- Now
- Time
- Today
- When
- Workdays
You can get more information about these functions in Minitab Help.
Let’s say you are trying to subset the worksheet below by a specific date. You only want information dated after 5/4/2012.
Date |
Widget Count |
4/30/2012 |
4 |
5/1/2012 |
5 |
5/2/2012 |
3 |
5/3/2012 |
5 |
5/4/2012 |
2 |
5/5/2012 |
5 |
5/6/2012 |
6 |
5/7/2012 |
7 |
5/8/2012 |
4 |
Go to Data > Subset Worksheet, select ‘Specify which rows to include’ and then click on Condition to the right of ‘Rows that Match’. The condition expression will be:
‘Date’ > date(“5/4/2012”)
The Date calculator function is typically used to extract the date portion of a value in your worksheet. For example, if you specify date("5/11/08 12:55:35 PM") under the expression of the Calculator, Minitab will output 5/11/08. However, this functionality is also required when trying to subset by a date value. In the expression above, by adding the date function we have informed Minitab that 5/4/2012 is a date value. Without it, Minitab doesn’t know whether 5/4/2012 is a text, numeric, or date/time value. You’ll also notice that double quotes were used around the value.
The resulting Subset should look something like this:
Date |
Widget Count |
5/5/2012 |
5 |
5/6/2012 |
6 |
5/7/2012 |
7 |
5/8/2012 |
4 |
Code
The last tool I want to mention is Code, which can be found in the Data menu. This is a good tool to use when you need to create labels or values based on date ranges. Let’s say that the range of 4/30/2012 to 5/4/2012 represents information from Machine A, and 5/5/2012 to 5/8/2012 represents Machine B. We can create a column that lists the two machines by using Code.
Go to Data > Code > Date/Time to Text. Fill in the Dialog Window as shown below:
After pressing OK, you should get a new column in your worksheet that lists Machine A or Machine B for each date!
I hope this information helps you to get more value out of your date and time data in Minitab!