Excel time from time and date

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

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.

Function

Description

DATE function

Returns the serial number of a particular date

DATEDIF function

Calculates the number of days, months, or years between two dates. This function is useful in formulas where you need to calculate an age.

DATEVALUE function

Converts a date in the form of text to a serial number

DAY function

Converts a serial number to a day of the month

DAYS function

Excel 2013

Returns the number of days between two dates

DAYS360 function

Calculates the number of days between two dates based on a 360-day year

EDATE function

Returns the serial number of the date that is the indicated number of months before or after the start date

EOMONTH function

Returns the serial number of the last day of the month before or after a specified number of months

HOUR function

Converts a serial number to an hour

ISOWEEKNUM function

Excel 2013

Returns the number of the ISO week number of the year for a given date

MINUTE function

Converts a serial number to a minute

MONTH function

Converts a serial number to a month

NETWORKDAYS function

Returns the number of whole workdays between two dates

NETWORKDAYS.INTL function

Excel 2010

Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days

NOW function

Returns the serial number of the current date and time

SECOND function

Converts a serial number to a second

TIME function

Returns the serial number of a particular time

TIMEVALUE function

Converts a time in the form of text to a serial number

TODAY function

Returns the serial number of today’s date

WEEKDAY function

Converts a serial number to a day of the week

WEEKNUM function

Converts a serial number to a number representing where the week falls numerically with a year

WORKDAY function

Returns the serial number of the date before or after a specified number of workdays

WORKDAY.INTL function

Excel 2010

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

YEAR function

Converts a serial number to a year

YEARFRAC function

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.

Need more help?

i have this string which is in a date and time format (10/25/2013 8:54:00 PM),i want to extract the time from each cell and sum them to find the total time.

please can someone suggest me how to do it???

asked Jun 24, 2014 at 14:42

zaygum's user avatar

5

Try this formula to extract the time:

=TIME(HOUR(A1),MINUTE(A1),SECOND(A1))

Then, summarize the values and use «d h:mm» number format for the cell.

answered Jun 24, 2014 at 15:00

alex.pulver's user avatar

alex.pulveralex.pulver

2,0892 gold badges32 silver badges31 bronze badges

0

Assuming your date format is MMDDYYYY h:mm:ss AM/PM. Use this formula to extract time value:

=TIMEVALUE(RIGHT(A1,LEN(A1)-11))

This value is in days. I.e. if there is 6 hours, the value will be 0.25. To get number of hours multiply it by 24.

answered Jun 24, 2014 at 14:49

ttaaoossuuuu's user avatar

ttaaoossuuuuttaaoossuuuu

7,7563 gold badges28 silver badges56 bronze badges

2

If your string is a properly-recognised Excel Date/Time format, simply:

=MOD(A1,1)

Format as hh:mm if you wish.

Regards

answered Jun 24, 2014 at 14:57

XOR LX's user avatar

XOR LXXOR LX

7,6321 gold badge16 silver badges15 bronze badges

0

If you values are in ColumnA (start) and B (corresponding finish) then something like:

=B1-A1  

formatted as Time should suit with summing of the results.

answered Jun 24, 2014 at 15:10

pnuts's user avatar

pnutspnuts

58k11 gold badges85 silver badges137 bronze badges

Are you tired of trying to extract date or time from datetime values in Excel? This post will show you how it’s done. Whether you need to separate the date component, the time component, or both, this guide has you covered. You’ll learn how to use formulas and functions to easily extract date or time from datetime values in Excel.

This post will guide you how to extract time from a data and time value with a formula in Excel. How do I extract time from a date-time number in Excel 2013/2016. How to extract hour only from the date time format in Excel.

Table of Contents

  • 1. Extract Date from Datetime
  • 2. Extract Date from Text String
  • 3. Extract Year from Date
  • 4. Concatenate Date and Time
  • 5. Extract Time from Date and Time
  • 6. Extract Hour only from Date and Time
  • 7. Split Date and Time in Excel
  • 8. Convert Unix Timestamp to a Date in Excel
  • 9. If function with dates
  • 10. Time Calculations in Excel
  • 11. Conclusion
  • 12. Related Functions

To extract or get the date from a datetime value in one cell in Excel, you can use the following formula:

=TEXT(datetime,"MM/DD/YYYY").

You need to replace “datetime” with the cell reference that contains the datetime value. This formula converts the datetime value to text in the desired date format (MM/DD/YYYY in this case).

Extract Date from Datetime

The result will be the date part of the datetime value, displayed as text string. If you need to use the result in further calculations, you can convert the result back to a date value by using the “DATEVALUE” function.

=DATEVALUE(B2)

Extract Date from Datetime

You can also use the “=INT()” function to convert a date and time to a date:

=INT(A2)

Extract Date from Datetime int function

This function will return the date portion of the date and time value as a serial number, which can be formatted as a date using the “Number Format” option in the “Home” tab of the Excel ribbon.

To extract the date from a text string in Excel, you can use the following formula:

=MID($A1,SEARCH("/??/",$A1,1)-2,10)

where A1 is the cell that contains the text string.

This formula uses the SEARCH function to locate the position of the date part in the string and the MID function to extract the date part of the string.

Extract Date from Text String

If you wish to extract the year part from a date value in Excel, you can use the YEAR function.

extract year from a date value1

The YEAR function takes a date as an argument and returns the year component of the date, as a number.

 For example, if cell A1 contains the date “02/08/2022“, you can extract the year using the following formula:

=YEAR(A1)

This formula will return the year “2022“.

4. Concatenate Date and Time

If you want to concatenate date and time in Microsoft Excel, you can use the “&” operator in combination with TEXT function to join the values in separate cells into one cell.

The Steps are as below:

Step 1: Enter the following formula in a empty cell:

=TEXT(A2,"MM/DD/YYYY") & " " & TEXT(B2,"HH:MM:SS")
  • Replace A2 and B2 with the cells that contain your date and time, respectively.
  • The formula uses the TEXT function to format the date and time values, and then joins them with a space in between.

Step 2: Press Enter to see the result of the formula.

concatenate date and time 1

Step 3: If you want to copy the result to multiple cells, simply select the cell with the formula, and then drag the fill handle to the cells you want to copy the formula to.

concatenate date and time 1

Your date and time values should now be combined into one cell in the format of “MM/DD/YYYY HH:MM:SS“.

5. Extract Time from Date and Time

If you want to extract time from a date and time in Excel, you can use a formula based on the TIME function, The HOUR function, the MINUTE function, and the SECOND function. For example, you want to get time value from a date and time value in Cell B1, you can write down the below formula.

=TIME(HOUR(B1),MINUTE(B1),SECOND(B1))

Step 1: Type this formula into a blank cell C1 and press Enter key.

extract time and hour1

Step 2: Then you need to right click on the Cell C1, and select Format Cell from the pop-up menu list. The Format Cells dialog will open.

extract time and hour2

Step 3: switch to Number tab, and click Custom from the Category list. And select one type as: h:mm:ss. Click OK button.

extract time and hour3

#4 let’s see the result.

extract time and hour4

6. Extract Hour only from Date and Time

If you want to extract hour only, you just need to use the HOUR function. Like this:

=HOUR(B1)

extract time and hour5

If you want to extract minute only from a date and time value, you just need to use the MINUTE function. Like this:

=MINUTE(B1)

extract time and hour6

If you want to extract second only from a date and time value, you just need to use the SECOND function. Like this:

=SECOND(B1)

extract time and hour7

7. Split Date and Time in Excel

If you want to split a date and time value into separate date and time values in Microsoft Excel, and you can use the above TEXT formula to Extract Date portion from date and time value.

Then you can use the below Text formula to extract the time portion of the date and time value:

=TEXT(A2,”HH:MM:SS”)

Alternatively, you can also use the INT function to extract the date portion of the date and time value, enter the following formula in a new cell:

=INT(A2)

Enter the following formula in another cell to extract the time portion:

=A2-INT(A1)

split date and time in excel1

These formulas will return the date and time portions of the date and time value as serial numbers, which can be formatted as dates and times using the “Number Format” option in the “Home” tab of the Excel ribbon.

8. Convert Unix Timestamp to a Date in Excel

If you wish to convert a Unix timestamp to a date in Microsoft Excel, you can use the following TEXT formula:

=TEXT((A1/86400)+DATE(1970,1,1),"MM/DD/YYYY HH:MM:SS")

convert unix timestamp to date1

In this formula, “A1” represents the cell that contains the Unix timestamp. The Unix timestamp is divided by 86400 to convert it to the number of days since January 1, 1970. The result is then added to the date “1/1/1970” to give the date and time corresponding to the Unix timestamp. The “TEXT()” function is used to format the result as a date and time in the “MM/DD/YYYY HH:MM:SS” format.

Note that the Unix timestamp is typically stored as an integer value representing the number of seconds since January 1, 1970, so you may need to divide the value in the cell by 86400 to convert it to a number of days.

9. If function with dates

The IF function in Microsoft Excel can be used with dates to perform conditional tests based on the values of dates. Here’s the general syntax for using the IF function with dates:

=IF(condition, [value_if_true], [value_if_false])

In this syntax, “condition” is the logical test that you want to perform, [value_if_true] is the value that will be returned if the condition is true, and [value_if_false] is the value that will be returned if the condition is false.

Here’s an example of using the IF function with dates:

=IF(A1>B1, "A1 is later", "B1 is later")

if function with dates1

In this example, the condition “A1>B1” checks if the date in cell A1 is later than the date in cell B1. If the condition is true, the result will be “A1 is later“, and if the condition is false, the result will be “B1 is later“.

Note: When working with dates in Excel, it’s important to ensure that the dates are stored as dates and not as text. You can format a cell as a date by selecting it, right-clicking, selecting “Format Cells“, and then selecting the “Date” category under “Number“. From the available date formats, select the one you want to use and click “OK“.

10. Time Calculations in Excel

You can perform various calculations with times to get the result in terms of hours, minutes, or seconds. Here are a few examples of time calculations in Excel:

Add two times:

=A1+B1

add two times in excel

In this example, the two times in cells A1 and B1 are added together to give the result in the same time format.

Subtract one time from another:

=A1-B1

subtract two times in excel

In this example, the time in cell B1 is subtracted from the time in cell A1 to give the result in terms of a time.

Calculate the difference between two times in hours:

=(A1-B1)*24

calculate the difference between two times in hours

In this example, the difference between the two times is calculated in terms of hours by multiplying the result of the subtraction by 24.

Calculate the difference between two times in minutes:

=(A1-B1)*1440

calculate the difference between two times in minutes

In this example, the difference between the two times is calculated in terms of minutes by multiplying the result of the subtraction by 1440 (24 hours * 60 minutes).

11. Conclusion

In conclusion, extracting dates or times from datetime values in Microsoft Excel is very useful for data analysis and manipulation. Whether you need to separate dates and times for the purpose of sorting or calculating, or just to display the information in a different format, there are several ways to achieve it. Excel offers a range of options for extracting date or time information from datetime values.

  • Excel TIME function
    The Excel TIME function returns a date in serial number format for a particular time (the hour, minute and second).The syntax of the TIME function is as below:= TIME(hour, minute, second)…
  • Excel HOUR Function
    The Excel HOUR function returns the hour of a time value. Or returns an integer value that represent the hour component of a given time. The syntax of the HOUR function is as below:=HOUR (serial_number) …
  • Excel MINUTE Function
    The Excel MINUTE function returns the minutes of a time value. And the minutes is an integer number from 0 to 59. The syntax of the MINUTE function is as below:=MINUTE (serial_number)…
  • Excel SECOND Function
    The Excel SECOND function returns the seconds of a time value. Or returns an integer value that represent the second component of a given excel time. And the return value is between 0-59.The syntax of the SECOND function is as below:=SECOND (serial_number)…

Summary

To extract the time from a date that contains time (sometimes called a «datetime»), you can use a formula based on the MOD function. In the example shown, the formula in D5 is:

=MOD(B5,1)

which returns the time portion of the value in B5, 1:00 PM.

Generic formula

Explanation 

Excel handles dates and times using a system in which dates are serial numbers and times are fractional values. For example, June 1, 2000 12:00 PM is represented in Excel as the number 36678.5, where 36678 is the date (June 1, 2000) and .5 is the time (12:00 PM). In other words, the time value in a «datetime» is the decimal.

The MOD function returns the remainder from division. The first argument is the number and the second is the divisor. Here are a few examples:

=MOD(5,2) // returns 1
=MOD(7,5) // returns 2

If you use MOD with a divisor of 1, the result will be the decimal part of the number, if any, because every whole number can be evenly divided by itself. For example:

=MOD(3.125,1) // returns 0.125

In short, =MOD(number,1) returns just the fractional part of a number, discarding the integer portion, so it’s a convenient way to extract time from a date.

Note: if you use this formula to strip the time from a date + time, you’ll need to apply a suitable number format to display as time.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi — I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.

There are hundreds and hundreds of Excel sites out there. I’ve been to many and most are an exercise in frustration. Found yours today and wanted to let you know that it might be the simplest and easiest site that will get me where I want to go.

Get Training

Quick, clean, and to the point training

Learn Excel with high quality video training. Our videos are quick, clean, and to the point, so you can learn Excel in less time, and easily review key topics when needed. Each video comes with its own practice worksheet.

View Paid Training & Bundles

Help us improve Exceljet

Sometimes you may have dates in one column and time values in another column and you want to combine these to get one single date and time value in a cell.

And if you’re thinking that you can do that by easily combining the two cells by using the concatenate formula or the & sign, you’ll find out that it doesn’t work.

I have tried to use the & sign to combine the cells that contain date and time, and the resulting value is not in the expected format.

In this tutorial, I will show you a couple of ways to quickly combine date and time values in Excel.

So let’s get started!

Combine Date and Time with a Simple Addition

Excel stores date and time values as numbers in the back end.

For example, 44197.375 in Excel represents 01-01-2021 09:00 AM

The integer part of the above number represents a date (which is 01 Jan 2021), and the decimal part of the number represents a time (which is 9 AM)

So, if you have dates in one column and time in another column, the easiest way to combine these and get the date and time in one single cell would be to simply add these two cells.

Suppose you have a data set as shown below and you want to combine the date and time in column C.

Date and Time in separate columns

Below is the formula that will do that:

=A2+B2
Simple addition to combine date and time

All this formula to all the cells in the column to get the combined date and time values.

It automatically picks up the format from the cells and shows you the result that has the date portion and the time portion.

As I mentioned, dates and times are stored as numbers in Excel. The combined date and time that you see in the cells in column C are also decimal numbers in the back end.

In case you want to show that result in a different format, you can do that using the format cells dialog box (where you can specify the custom code to show the date and time in a specific way).

In most cases, Excel will take care of the formatting and you will see the date as well as the time as shown above. In case it doesn’t, you will have to change the cell formatting to show the combined date and time.

Combine Date and Time with a TEXT Function

Another quick way to combine date and time in Excel is by using the CONCAT formula with the TEXT function.

Suppose you have a dataset as shown below and you want to combine the date and time and get the result in column C.

Date and Time in separate columns

Below is the formula that can do this:

=CONCAT(TEXT(A2,"dd-mm-yyy")," ",TEXT(B2,"hh:mm:ss"))
Formula to combine date and time

The TEXT function allows you to take any value as the input and show it in the specified format.

In our example, I have used two TEXT functions, the first one takes the date value and displays it as a date and the second one takes the time value and displays it as the time.

And since I want both of these in the same cell, I have used the CONCAT formula with space as the separator in between the date and time.

Since we have used the TEXT function to specify the format for the date and the time, it does not matter how the input values are displayed in the cell.

For example, even if I have the numerical values instead of the date and the time, this formula would still give me the right result.

Another big benefit of using the text function is that you can combine other text strings with the result of this formula.

To give you an example, let’s say I don’t want just the date and the time, I want the result in the following format – Date: 01 Jan 2021, Time: 09:00 AM

To do this, you can use the below formula:

=CONCAT("Date: "&TEXT(A2,"dd-mm-yyy"),", ","Time: "&TEXT(B2,"hh:mm:ss AM/PM"))
Formula to combine date and time with custom text

Since the result of the TEXT function is a text string, we can easily combine it with the other text strings using the ampersand operator (&) or CONCAT formula.

So these are two simple ways you can use to combine date and time in Excel.

I hope you found this tutorial useful.

Other Excel tutorials you may also like:

  • Calculate Time in Excel (Time Difference, Hours Worked, Add/ Subtract)
  • Convert Time to Decimal Number in Excel (Hours, Minutes, Seconds)
  • How to Remove Time from Date/Timestamp in Excel
  • How to Quickly Insert Date and Timestamp in Excel
  • How to Change Date Format In Excel?
  • How to Add Months to Date in Excel
  • How to Compare Dates in Excel (Greater/Less Than, Mismatches)

Понравилась статья? Поделить с друзьями:
  • Excel time code to date
  • Excel time between dates
  • Excel this row number
  • Excel this row in formula
  • Excel this cell row