|
-
Jan 22nd, 2003, 01:25 PM
#1
Thread Starter
Junior Member
time function
i want to add 33 hours 20 min 22 sec in
7 :30:00 How to do this .
any one have sugg??
-
Jan 22nd, 2003, 01:33 PM
#2
PowerPoster
youll have to apply the DateAdd function to it 3 times (one for hours, one for minutes, and one for seconds) I think.
-
Jan 22nd, 2003, 01:41 PM
#3
Frenzied Member
VB Code:
newtime = Format(DateAdd("h", 33, DateAdd("n", 20, DateAdd("s", 22, Text1.Text))), "hh:mm:ss ampm")
-
Jan 22nd, 2003, 01:43 PM
#4
Frenzied Member
Something like this:
VB Code:
Private Sub Form_Load()
Dim CurTime As String
Dim TimeToAdd As String
Dim NewTime As String
CurTime = Format(Now, "mm/dd/yyyy ") & Format("7:30:00", "hh:nn:ss")
TimeToAdd = "33:20:22"
NewTime = DateAdd("h", CDbl(Left(TimeToAdd, 2)), CurTime)
NewTime = DateAdd("n", CDbl(Mid(TimeToAdd, 4, 2)), NewTime)
NewTime = DateAdd("s", CDbl(Right(TimeToAdd, 2)), NewTime)
Debug.Print NewTime
End Sub
-
Jan 22nd, 2003, 01:48 PM
#5
Frenzied Member
If you just want the time returned (no date) then...
This will add to the time and return the new time...
VB Code:
Private Function TimeAdd(dTime As Date, nHours As Integer, nMinutes As Integer, _
nSeconds As Integer) As Date
TimeAdd = FormatDateTime(DateAdd("h", nHours, (DateAdd("n", nMinutes, _
DateAdd("s", nSeconds, dTime)))), vbLongTime)
End Function
Usage:
VB Code:
Dim NewTime as Date
NewTime = TimeAdd("7:30:00 AM", 33, 20, 22)
-
Jan 22nd, 2003, 03:46 PM
#6
PowerPoster
Re: If you just want the time returned (no date) then...
Originally posted by seaweed
This will add to the time and return the new time...
VB Code:
Private Function TimeAdd(dTime As Date, nHours As Integer, nMinutes As Integer, _
nSeconds As Integer) As Date
TimeAdd = FormatDateTime(DateAdd("h", nHours, (DateAdd("n", nMinutes, _
DateAdd("s", nSeconds, dTime)))), vbLongTime)
End Function
Usage:
VB Code:
Dim NewTime as Date
NewTime = TimeAdd("7:30:00 AM", 33, 20, 22)
Nice
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|