J
jonesfranckandi
Hi everyone,
I have managed to create a module that calculate (countdown) the number
of remain time form the end date. this is in days, Hours, Minutes and
seconds. But I want to extend it to years and month. I can do the year
bit but the month's one is hard because each month may have different
numbers of days ( february:28 or 29 days, some have 30 days and others
31 days.). I tried to continue with Mod with a fixed value but it is
not what I expected. I nedd help.Can anyone help me Please!!!!
Your help will be much appreciated. The code I have so far is below.
Thanks in advance.
Public Function CountDown(EndTime as Variant) as String
Dim lTemp as long
Dim D as Integer, H as Integer, M as Integer, S as Integer
If Not IsDate(EndTime) then Exit Function
lTemp = DateDiff("s", Now, EndTime)
S = lTemp Mod 60
lTemp = lTemp \ 60
M = lTemp Mod 60
lTemp = lTemp \ 60
H = lTemp Mod 24
D = lTemp \ 24
CountDown = D & " Day(s): " & H & " Hour(s):" _
& M & " Minute(s): " & S & " Second(s)"
End Function
I have managed to create a module that calculate (countdown) the number
of remain time form the end date. this is in days, Hours, Minutes and
seconds. But I want to extend it to years and month. I can do the year
bit but the month's one is hard because each month may have different
numbers of days ( february:28 or 29 days, some have 30 days and others
31 days.). I tried to continue with Mod with a fixed value but it is
not what I expected. I nedd help.Can anyone help me Please!!!!
Your help will be much appreciated. The code I have so far is below.
Thanks in advance.
Public Function CountDown(EndTime as Variant) as String
Dim lTemp as long
Dim D as Integer, H as Integer, M as Integer, S as Integer
If Not IsDate(EndTime) then Exit Function
lTemp = DateDiff("s", Now, EndTime)
S = lTemp Mod 60
lTemp = lTemp \ 60
M = lTemp Mod 60
lTemp = lTemp \ 60
H = lTemp Mod 24
D = lTemp \ 24
CountDown = D & " Day(s): " & H & " Hour(s):" _
& M & " Minute(s): " & S & " Second(s)"
End Function