Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
This article describes the formula syntax and usage of the TIME function in Microsoft Excel.
Description
Returns the decimal number for a particular time. If the cell format was General before the function was entered, the result is formatted as a date.
The decimal number returned by TIME is a value ranging from 0 (zero) to 0.99988426, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).
Syntax
TIME(hour, minute, second)
The TIME function syntax has the following arguments:
-
Hour Required. A number from 0 (zero) to 32767 representing the hour. Any value greater than 23 will be divided by 24 and the remainder will be treated as the hour value. For example, TIME(27,0,0) = TIME(3,0,0) = .125 or 3:00 AM.
-
Minute Required. A number from 0 to 32767 representing the minute. Any value greater than 59 will be converted to hours and minutes. For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM.
-
Second Required. A number from 0 to 32767 representing the second. Any value greater than 59 will be converted to hours, minutes, and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 or 12:33:20 AM
Remark
Time values are a portion of a date value and represented by a decimal number (for example, 12:00 PM is represented as 0.5 because it is half of a day).
Example
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Hour |
Minute |
Second |
---|---|---|
12 |
0 |
0 |
16 |
48 |
10 |
Formula |
Description |
Result |
=TIME(A2,B2,C2) |
Decimal part of a day, for the time specified in row 2 (12 hours, 0, minutes, 0 seconds) |
0.5 |
=TIME(A3,B3,C3) |
Decimal part of a day, for the time specified in row 3 (16 hours, 48 minutes, 10 seconds) |
0.7001157 |
See Also
Add or subtract time
Insert the current date and time in a cell
Date and time functions reference
Need more help?
The current date and time is a very common piece of data needed in a lot of Excel solutions.
The great news is there a lot of ways to get this information into Excel.
In this post, we’re going to look at 5 ways to get either the current date or current time into our workbook.
Video Tutorial
Keyboard Shortcuts
Excel has two great keyboard shortcuts we can use to get either the date or time.
These are both quick and easy ways to enter the current date or time into our Excel workbooks.
The dates and times created will be current when they are entered, but they are static and won’t update.
Current Date Keyboard Shortcut
Pressing Ctrl + ; will enter the current date into the active cell.
This shortcut also works while in edit mode and will allow us to insert a hardcoded date into our formulas.
Current Time Keyboard Shortcut
Pressing Ctrl + Shift + ; will enter the current time into the active cell
This shortcut also works while in edit mode and will allow us to insert a hardcoded date into our formulas.
Functions
Excel has two functions that will give us the date and time.
These are volatile functions, which means any change in the Excel workbook will cause them to recalculate. We will also be able to force them to recalculate by pressing the F9 key.
This means the date and time will always update to the current date and time.
TODAY Function
= TODAY()
This is a very simple function and has no arguments.
It will return the current date based on the user’s PC settings.
This means if we include this function in a workbook and send it to someone else in a different time zone, their results could be different.
NOW Function
= NOW()
This is also a simple function with no arguments.
It will return the current date and time based on the user’s PC date and time setting.
Again, someone in a different time zone will get different results.
Power Query
In Power Query, we only have one function to get both the current date and current time. We can then use other commands to get either the date or time from the date-time.
We first need to add a new column for our date-time. Go to the Add Column tab and create a Custom Column.
= DateTime.LocalNow()
In the Custom Column dialog box.
- Give the new column a name like Current DateTime.
- Enter the DateTime.LocalNow function in the formula section.
- Press the OK button.
Extract the Date
Now that we have our date-time column, we can extract the date from it.
We can select the date-time column ➜ go to the Add Column tab ➜ select the Date command ➜ then choose Date Only.
= Table.AddColumn(#"Added Custom", "Date", each DateTime.Date([Current DateTime]), type date)
This will generate a new column containing only the current date. Power query will automatically generate the above M code with the DateTime.Date function to get only the date.
Extract the Time
We can also extract the time from our date-time column.
We can select the date-time column ➜ go to the Add Column tab ➜ select the Time command ➜ then choose Time Only.
= Table.AddColumn(#"Added Custom", "Time", each DateTime.Time([Current DateTime]), type time)
This will generate a new column containing only the current time. Power query will automatically generate the above M code with the DateTime.Time function to get only the time.
Power Pivot
With power pivot, there are two ways to get the current date or time. We can create a calculated column or a measure.
To use power pivot, we need to add our data to the data model first.
- Select the data.
- Go to the Power Pivot tab.
- Choose the Add to Data Model command.
Power Pivot Calculated Column
A calculated column will perform the calculation for each row of data in our original data set. This means we can use the calculated column as a new field for our Rows or Columns area in our pivot tables.
= TODAY()
= NOW()
It turns out Power Pivot has the exact same TODAY and NOW functions as Excel!
We can then add a new calculated column inside the power pivot add in.
- Double click on the Add Column and give the new column a name. Then select any cell in the column and enter the TODAY function and press Enter.
- Go to the Home tab ➜ Change the Data Type to Date ➜ Change the Format to any of the date formats available.
We can do the exact same to add our NOW function to get the time and then format the column with a time format.
Power Pivot Measure
Another option with power pivot is to create a measure. Measures are calculations that aggregate to a single value and can be used in the Values area of a pivot table.
Again, we can use the same TODAY and NOW functions for our measures.
Add a new measure.
- Go to the Power Pivot tab.
- Select the Measures command.
- Select New Measure.
This will open up the Measure dialog box where we can define our measure calculation.
- Give the new measure a name.
- Add the TODAY or NOW function to the formula area.
- Select a Date Category.
- Select either a date or time format option.
- Press the OK button.
Now we can add our new measure into the Values area of our pivot table.
Power Automate
If you’re adding or updating data in Excel through some automated process via Power Automate, then you might want to add a timestamp indicating when the data was added or last updated.
We can definitely add the current date or time into Excel from Power Automate.
We will need to use an expression to get either the current date or time. Power Automate expressions for the current time will result in a time in UTC which will then need to be converted into the desired timezone.
= convertFromUtc(utcNow(),'Eastern Standard Time','yyyy-MM-dd')
This expression will get the current date in the EST timezone. You can find a list of all the timezone’s here.
= convertFromUtc(utcNow(),'Eastern Standard Time','hh:mm:ss')
This expression will get the current time in the EST timezone.
Conclusions
Like most things in Excel, there are many ways to get the current date and time in Excel.
Some are static like the keyboard shortcuts. They will never update after entering them, but this may be exactly what we need.
The other methods are dynamic but need to be recalculated or refreshed.
Do you have any other methods? Let me know in the comments!
About the Author
John is a Microsoft MVP and qualified actuary with over 15 years of experience. He has worked in a variety of industries, including insurance, ad tech, and most recently Power Platform consulting. He is a keen problem solver and has a passion for using technology to make businesses more efficient.
Содержание
- Date and time functions (reference)
- Insert the current date and time in a cell
- Insert a static date or time into an Excel cell
- Change the date or time format
- Insert a static date or time into an Excel cell
- Change the date or time format
- Insert a static date or time into an Excel cell
- Change the date or time format
- Insert a date or time whose value is updated
- Need more help?
- TIME function
- Description
- Syntax
- Remark
- Example
- Functions HOUR, MINUTE and SECOND to work with time in Excel
- Examples of using the functions HOUR, MINUTE and SECOND for calculations in Excel
- Monitoring the daily time clock in Excel using the HOUR function
- Conversion of numbers to time format using the functions HOUR and MINUTE
- Example of using the SECOND function in Excel
- Features syntax functions HOUR, MINUTE and SECOND in Excel
Date and time functions (reference)
To get detailed information about a function, click its name in the first column.
Note: Version markers indicate the version of Excel a function was introduced. These functions aren’t available in earlier versions. For example, a version marker of 2013 indicates that this function is available in Excel 2013 and all later versions.
Returns the serial number of a particular date
Calculates the number of days, months, or years between two dates. This function is useful in formulas where you need to calculate an age.
Converts a date in the form of text to a serial number
Converts a serial number to a day of the month
DAYS function
Returns the number of days between two dates
Calculates the number of days between two dates based on a 360-day year
Returns the serial number of the date that is the indicated number of months before or after the start date
Returns the serial number of the last day of the month before or after a specified number of months
Converts a serial number to an hour
ISOWEEKNUM function
Returns the number of the ISO week number of the year for a given date
Converts a serial number to a minute
Converts a serial number to a month
Returns the number of whole workdays between two dates
NETWORKDAYS.INTL function
Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days
Returns the serial number of the current date and time
Converts a serial number to a second
Returns the serial number of a particular time
Converts a time in the form of text to a serial number
Returns the serial number of today’s date
Converts a serial number to a day of the week
Converts a serial number to a number representing where the week falls numerically with a year
Returns the serial number of the date before or after a specified number of workdays
WORKDAY.INTL function
Returns the serial number of the date before or after a specified number of workdays using parameters to indicate which and how many days are weekend days
Converts a serial number to a year
Returns the year fraction representing the number of whole days between start_date and end_date
Important: The calculated results of formulas and some Excel worksheet functions may differ slightly between a Windows PC using x86 or x86-64 architecture and a Windows RT PC using ARM architecture. Learn more about the differences.
Источник
Insert the current date and time in a cell
Let’s say that you want to easily enter the current date and time while making a time log of activities. Or perhaps you want to display the current date and time automatically in a cell every time formulas are recalculated. There are several ways to insert the current date and time in a cell.
Insert a static date or time into an Excel cell
A static value in a worksheet is one that doesn’t change when the worksheet is recalculated or opened. When you press a key combination such as Ctrl+; to insert the current date in a cell, Excel “takes a snapshot” of the current date and then inserts the date in the cell. Because that cell’s value doesn’t change, it’s considered static.
On a worksheet, select the cell into which you want to insert the current date or time.
Do one of the following:
To insert the current date, press Ctrl+; (semi-colon).
To insert the current time, press Ctrl+Shift+; (semi-colon).
To insert the current date and time, press Ctrl+; (semi-colon), then press Space, and then press Ctrl+Shift+; (semi-colon).
Change the date or time format
To change the date or time format, right-click on a cell, and select Format Cells. Then, on the Format Cells dialog box, in the Number tab, under Category, click Date or Time and in the Type list, select a type, and click OK.
Insert a static date or time into an Excel cell
A static value in a worksheet is one that doesn’t change when the worksheet is recalculated or opened. When you press a key combination such as Ctrl+; to insert the current date in a cell, Excel “takes a snapshot” of the current date and then inserts the date in the cell. Because that cell’s value doesn’t change, it’s considered static.
On a worksheet, select the cell into which you want to insert the current date or time.
Do one of the following:
To insert the current date, press Ctrl+; (semi-colon).
To insert the current time, press + ; (semi-colon).
To insert the current date and time, press Ctrl+; (semi-colon), then press Space, and then press + ; (semi-colon).
Change the date or time format
To change the date or time format, right-click on a cell, and select Format Cells. Then, on the Format Cells dialog box, in the Number tab, under Category, click Date or Time and in the Type list, select a type, and click OK.
Insert a static date or time into an Excel cell
A static value in a worksheet is one that doesn’t change when the worksheet is recalculated or opened. When you press a key combination such as Ctrl+; to insert the current date in a cell, Excel “takes a snapshot” of the current date and then inserts the date in the cell. Because that cell’s value doesn’t change, it’s considered static.
On a worksheet, select the cell into which you want to insert the current date or time.
Do one of the following:
To insert the date, type the date (like 2/2), and then click Home > Number Format dropdown (in the Number tab) > Short Date or Long Date.
To insert the time, type the time, and then click Home > Number Format dropdown (in the Number tab) > Time.
Change the date or time format
To change the date or time format, right-click on a cell, and select Number Format. Then, on the Number Format dialog box, under Category, click Date or Time and in the Type list, select a type, and click OK.
Insert a date or time whose value is updated
A date or time that updates when the worksheet is recalculated or the workbook is opened is considered “dynamic” instead of static. In a worksheet, the most common way to return a dynamic date or time in a cell is by using a worksheet function.
To insert the current date or time so that it is updatable, use the TODAY and NOW functions, as shown in the following example. For more information about how to use these functions, see TODAY function and NOW function.
Current date (varies)
Current date and time (varies)
Select the text in the table shown above, and then press Ctrl+C.
In the blank worksheet, click once in cell A1, and then press Ctrl+V. If you are working in Excel for the web, repeat copying and pasting for each cell in the example.
Important: For the example to work properly, you must paste it into cell A1 of the worksheet.
To switch between viewing the results and viewing the formulas that return the results, press Ctrl+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.
Note: The results of the TODAY and NOW functions change only when the worksheet is calculated or when a macro that contains the function is run. Cells that contain these functions are not updated continuously. The date and time that are used are taken from the computer’s system clock.
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
Источник
TIME function
This article describes the formula syntax and usage of the TIME function in Microsoft Excel.
Description
Returns the decimal number for a particular time. If the cell format was General before the function was entered, the result is formatted as a date.
The decimal number returned by TIME is a value ranging from 0 (zero) to 0.99988426, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).
Syntax
TIME(hour, minute, second)
The TIME function syntax has the following arguments:
Hour Required. A number from 0 (zero) to 32767 representing the hour. Any value greater than 23 will be divided by 24 and the remainder will be treated as the hour value. For example, TIME(27,0,0) = TIME(3,0,0) = .125 or 3:00 AM.
Minute Required. A number from 0 to 32767 representing the minute. Any value greater than 59 will be converted to hours and minutes. For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM.
Second Required. A number from 0 to 32767 representing the second. Any value greater than 59 will be converted to hours, minutes, and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 or 12:33:20 AM
Time values are a portion of a date value and represented by a decimal number (for example, 12:00 PM is represented as 0.5 because it is half of a day).
Example
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Источник
Functions HOUR, MINUTE and SECOND to work with time in Excel
Excel defaults to date and time functions: HOUR, MINUTE and SECOND. Consider in detail these three functions in action on specific examples. How, when and where they can be effectively applied, making up various formulas from these functions for working with time.
Examples of using the functions HOUR, MINUTE and SECOND for calculations in Excel
The HOUR function in Excel is designed to determine the hour value from the transmitted time as a parameter and returns data from a range of numeric values from 0 to 23, depending on the format of the temporary record.
The function MINUTE in Excel is used to get the minutes from the transmitted data, which characterizes the time, and returns data from a range of numeric values from 0 to 59.
The SECOND function in Excel is used to get the seconds from data in a time format and returns numeric values from 0 to 59.
Monitoring the daily time clock in Excel using the HOUR function
Example 1. Get the current time, determine how many hours have passed since the beginning of the current day, how many hours left before the beginning of a new day.
Let’s define the current moment in the Excel time code:
Calculate the number of hours from the beginning of the day:
- B2 — the current date and time, expressed in the format Date.
Determine the number of hours before the end of the day:
- 24 — the number of hours per day;
- B3 is the current time in hours, expressed as a numerical value.
Note: The example demonstrates that the result of the work of the HOUR function is a number on which you can perform any arithmetic operation.
Conversion of numbers to time format using the functions HOUR and MINUTE
Example 2. From the application, moments of passing certain events that were recognized by Excel as ordinary numbers were loaded (for example, 13:05 was recognized as the number 1305). It is necessary to convert the obtained values into the time format, select the hours and minutes.
Source data table:
To convert the data, use the function:
- B3 — the value recognized by Excel as a normal number;
- «00:00» is the time format.
As a result, we get:
Using the functions HOUR and MINUTE, select the desired values. Similarly, we define the required values for the remaining events:
Example of using the SECOND function in Excel
Example 3. The work day starts at 8:00 am. One worker was systematically late for the previous 10 working days for a few seconds. Determine the total time the employee is late.
Enter the data in the table:
Determine the delay in seconds. Where B3 — data on the time of arrival at work on the first day. Similarly, we define the seconds of delay for the following days:
Determine the total number of seconds of delay:
Where C3:C12 is an array of cells containing seconds of late values. We define the integer value of the minutes of delay, knowing that in 1 min = 60 seconds. As a result, we get:
That is, the total lateness of an employee for 10 days was 263 seconds, which is more than 4 minutes.
Features syntax functions HOUR, MINUTE and SECOND in Excel
The HOUR function has the following syntax entry:
- serial_number is the only function argument (required) that characterizes time data that contains data about the clock.
- If a string with text that does not contain time information is passed as an argument to the HOUR function, the error code #VAL! Will be returned.
- If the logical data type (TRUE, FALSE) or a reference to an empty cell was passed as an argument to the HOUR function, the value 0 will be returned.
- There are several permitted data formats that the HOUR function accepts:
- In Excel time code (range of values from 0 to 2958465), while the integers correspond to days, fractional — hours, minutes and seconds. For example, 43284.5 is the number of days elapsed between the current moment and the starting point of reference in Excel (01/01/1900 is a conditional date). Fractional part 0.5 corresponds to 12 hours (half of the day).
- In the form of a text string, for example =HOUR(“11:57”). The result of the function — the number 11.
- In the format of the Date and Time Excel. For example, the function will return the values of the clock if, as an argument, it receives a reference to the cell containing the value “07/03/18 11:24” in the date format.
- As a result of the function that returns data in a time format. For example, the function =HOUR(TIMEVALUE(“1:34”)) returns the value 1.
The MINUTE function has the following syntax:
- serial_number is a required argument describing the value from which the minutes will be calculated.
- As in the case of the HOUR function, the MINUTE function accepts text and numeric data in the format of Dates and Times.
- If the argument of this function is an empty text string (“”) or a string containing text (“some text”), the error #VALUE! Will be returned.
- The function supports date format in Excel time code (for example, =MINUTE(0.34) returns the value 9).
The syntax of the SECOND function in Excel is:
- serial_number is the only argument represented as data from which the seconds will be calculated (required for filling).
- The SECOND function works with text and numeric data types representing Date and Time in Excel.
- Error #VALUE! will occur in cases where the argument is a text string that does not contain data characterizing the time.
- The function also calculates seconds from the number represented in the Excel time code (for example, =SECOND(9,567) returns the value 29).
Источник
Purpose
Create a time with hours, minutes, and seconds
Return value
A decimal number representing a particular time in Excel.
Usage notes
The TIME function creates a valid Excel time based with supplied values for hour, minute, and second. Like all Excel time, the result is a number that represents a fractional day. The TIME function will only return time values up to one full day, between 0 (zero) to 0.99999999, or 0:00:00 to 23:59:59. To see results formatted as time, apply a time-based number format.
Examples
=TIME(3,0,0) // 3 hours
=TIME(0,3,0) // 3 minutes
=TIME(0,0,3) // 3 seconds
=TIME(8,30,0) // 8.5 hours
The TIME function can interpret units in larger increments. For example, both of the formulas below return a result of 2 hours:
=TIME(0,120,0) // 2 hours
=TIME(0,0,7200) // 2 hours
However, when total time reaches 24 hours, the TIME function will «reset» to zero.
=TIME(12,0,0) // 12 hours
=TIME(36) // 12 hours
In this way, TIME behaves like a 24 hour clock that resets when it crosses midnight. Notably, TIME will not handle numeric inputs larger 32,767. For example, even though there are 86,400 seconds in a day, the following formula (which represents 12 hours) will fail with a #NUM! error:
=TIME(0,0,43200) // returns #NUM!
As a workaround, you can convert hours, minutes, and seconds directly to Excel time with a formula:
=hours/24+minutes/1440+seconds/86400
The result is the same as the TIME function up to 24 hours. Over 24 hours, this formula will continue to accumulate time, unlike the TIME function.
Notes
- When total time reaches 24 hours, the TIME function will «reset» to zero.
- The largest number that TIME will allow for hour, minute, or second is 32,767. Larger values will return a #NUM! error.
Excel can display the current time using the NOW function. This step by step tutorial will assist all levels of Excel users in calculating a time difference in different formats.
Figure 1. Final result
Syntax of the NOW formula
=NOW()
The NOW function has no parameters and returns the current time and date. To get only the time we will need to format the cell accordingly.
Setting up Our Data for Displaying the Current Time
Our table consists of 2 columns: “Current Time” (column B) and “Format ” (column C). In column B, we want to get a current time, while in column C we have a format of the appropriate time.
Figure 2. Data that we will use in the current time displaying
Displaying the Current Time
In our example, we want to display the current time in the cell B3 in format h:mm:ss AM/PM. Before applying the formula, we must set the format of the resulting cell as a time. To do this, we need to press Ctrl+1, choose “Custom” category and enter the format of the time – h:mm:ss AM/PM.
Figure 3. Formatting the cells for displaying the current time
Formula:
=NOW()
Setting the cell format like this, we will get the current time in hours, minutes and seconds and AM/PM.
Similarly, in the cell B4, we want to get the current time in hours and minutes AM/PM, while in the cells B5 and B6 we at to get the current time in formats h:mm:ss and h:mm without AM/PM.
To get the current time using the NOW formula, we need to follow these steps:
- Select cell B3 and click on it
- Press Ctrl+1
- Choose “Custom” category and enter the format of the time – h:mm:ss AM/PM
- Insert the formula: =NOW()
- Press enter
- Select cell B4 and click on it
- Press Ctrl+1
- Choose “Custom” category and enter the format of the time – h:mm AM/PM
- Insert the formula: =NOW()
- Press enter
- Select cell B5 and click on it
- Press Ctrl+1
- Choose “Custom” category and enter the format of the time – h:mm:ss
- Insert the formula: =NOW()
- Press enter
- Select cell B6 and click on it
- Press Ctrl+1
- Choose “Custom” category and enter the format of the time – h:mm
- Insert the formula: =NOW()
- Press enter
Figure 4. Displaying the current time in different formats using the NOW formula
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.