One cell calculation Excel - Time Interval
Solved/Closed
Related:
- One cell calculation Excel - Time Interval
- Popcorn time download - Download - Movies, series and TV
- Ocarina of time rom - Download - Action and adventure
- Calculation is incomplete. recalculate before saving - Guide
- Whatsapp time setting - Guide
- Vat calculation excel - Guide
3 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jul 7, 2010 at 11:26 AM
Jul 7, 2010 at 11:26 AM
So would your data always look like
<date 1><space><time 1><space><date2><space><time 2>
or could you have other combinations too ?
<date 1><space><time 1><space><date2><space><time 2>
or could you have other combinations too ?
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jul 7, 2010 at 07:36 PM
Jul 7, 2010 at 07:36 PM
Try this. You need to format the cell as number to decimal position as you desire. or you can send the formatted value from here like DateDiff = Format((CDate(sDt2) - CDate(sDt1)) * 24, "0")
Public Function DateDiff(ByVal sDateString As Range) As Variant Dim vPos As String Dim sDt1 As String Dim sDt2 As String If Trim(sDateString) = vbNullString Then DateDiff = vbNullString Else vPos = InStr(1, sDateString, " ") ' marks end of date part 1 vPos = InStr(vPos + 1, sDateString, " ") ' marks end of time part 1 sDt1 = Left(sDateString, vPos - 1) ' date and time part 1 sDt2 = Mid(sDateString, vPos + 1) ' date and time part 2 DateDiff = (CDate(sDt2) - CDate(sDt1)) * 24 End If End Function
Jul 7, 2010 at 12:53 PM