ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DAY BETWEEN TWO DATES AND TIME (https://www.excelbanter.com/excel-programming/319228-day-between-two-dates-time.html)

[email protected]

DAY BETWEEN TWO DATES AND TIME
 
I would like to know how many days between two dates and time.
Exemple: 1 Dec 14:00 to 3 Dec 21:00, will be 2 days but I want to know
how many days it will when you go over 6 hours more than the 24 hours.
The exemple shown it will be 3 days.
You can reply via my email:


DMoney

DAY BETWEEN TWO DATES AND TIME
 
Try this out - edit the ranges to match your date locations - never tried
this before, but i think this will get the answer u need.

Dim tst As Variant
Dim tst1 As Variant
Dim tst3 As Variant

tst1 = DateDiff("d", Range("G12"), Range("H12"))
tst = DateDiff("h", Range("G12"), Range("H12")) / 24
tst = Left(tst, 4)
tst = Right(tst, 3)
If tst = 0.29 Then
tst3 = tst1 + 1
Else
tst3 = tst1
End If
MsgBox tst3

Devin

" wrote:

I would like to know how many days between two dates and time.
Exemple: 1 Dec 14:00 to 3 Dec 21:00, will be 2 days but I want to know
how many days it will when you go over 6 hours more than the 24 hours.
The exemple shown it will be 3 days.
You can reply via my email:



Bob Phillips[_7_]

DAY BETWEEN TWO DATES AND TIME
 
Here is a formula solution

=INT(B1-A1)+1+(MOD((B1-A1),1)0.25)*1

--
HTH

-------

Bob Phillips
"DMoney" wrote in message
...
Try this out - edit the ranges to match your date locations - never

tried
this before, but i think this will get the answer u need.

Dim tst As Variant
Dim tst1 As Variant
Dim tst3 As Variant

tst1 = DateDiff("d", Range("G12"), Range("H12"))
tst = DateDiff("h", Range("G12"), Range("H12")) / 24
tst = Left(tst, 4)
tst = Right(tst, 3)
If tst = 0.29 Then
tst3 = tst1 + 1
Else
tst3 = tst1
End If
MsgBox tst3

Devin

" wrote:

I would like to know how many days between two dates and time.
Exemple: 1 Dec 14:00 to 3 Dec 21:00, will be 2 days but I want to know
how many days it will when you go over 6 hours more than the 24 hours.
The exemple shown it will be 3 days.
You can reply via my email:





BonjourMonde

DAY BETWEEN TWO DATES AND TIME
 
Do I have to make a MACRO for this one?


BonjourMonde

DAY BETWEEN TWO DATES AND TIME
 
This is give me 4 days not 3. Thanks


Bob Phillips[_7_]

DAY BETWEEN TWO DATES AND TIME
 
Sorry, mi-read part, try

=INT(B1-A1)+(MOD((B1-A1),1)0.25)*1

instead

--
HTH

-------

Bob Phillips
"BonjourMonde" wrote in message
oups.com...
This is give me 4 days not 3. Thanks




BonjourMonde

DAY BETWEEN TWO DATES AND TIME
 
Thanks, it works.



All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com