HOW TO CHANGE THE TIMING 15 MIN EARLY THAN CURRENT TIME OR TIME VALUE WHICH IS IN MS-ACCESS TABLE USING VB6.0??????????????????

plZ HELP ITS URGENT ??????????????????

In a module add the following - This is to get the time difference between 2 times -

Public Function GetTimeDiff(TimeStart, TimeEnd, txtResult As TextBox)

Dim diff As Long
diff = DateDiff("s", TimeStart, TimeEnd)

TimeString diff, txtResult
End Function

Public Function TimeString(Seconds As Long, txtResult As TextBox, Optional Verbose As Boolean = False) As String

'if verbose = false, returns
'something like
'02:22.08
'if true, returns
'2 hours, 22 minutes, and 8 seconds

Dim lHrs As Long
Dim lMinutes As Long
Dim lSeconds As Long

lSeconds = Seconds

lHrs = Int(lSeconds / 3600)
lMinutes = (Int(lSeconds / 60)) - (lHrs * 60)
lSeconds = Int(lSeconds Mod 60)

Dim sAns As String

If lSeconds = 60 Then
    lMinutes = lMinutes + 1
    lSeconds = 0
End If

If lMinutes = 60 Then
    lMinutes = 0
    lHrs = lHrs + 1
End If

sAns = Format(CStr(lHrs), "#####0") & ":" & _
  Format(CStr(lMinutes), "00") & "." & _
  Format(CStr(lSeconds), "00")

If Verbose Then sAns = TimeStringtoEnglish(sAns)
TimeString = sAns
txtResult.Text = TimeString
End Function

Public Function TimeStringtoEnglish(sTimeString As String) As String

Dim sAns As String
Dim sHour, sMin As String, sSec As String
Dim iTemp As Integer, sTemp As String
Dim iPos As Integer
iPos = InStr(sTimeString, ":") - 1

sHour = Left$(sTimeString, iPos)
If CLng(sHour) <> 0 Then
    sAns = CLng(sHour) & " hour"
    If CLng(sHour) > 1 Then sAns = sAns & "s"
    sAns = sAns & ", "
End If

sMin = Mid$(sTimeString, iPos + 2, 2)

iTemp = sMin

If sMin = "00" Then
   sAns = IIf(Len(sAns), sAns & "0 minutes, and ", "")
Else
   sTemp = IIf(iTemp = 1, " minute", " minutes")
   sTemp = IIf(Len(sAns), sTemp & ", and ", sTemp & " and ")
   sAns = sAns & Format$(iTemp, "##") & sTemp
End If

iTemp = Val(Right$(sTimeString, 2))
sSec = Format$(iTemp, "#0")
sAns = sAns & sSec & " second"
If iTemp <> 1 Then sAns = sAns & "s"

TimeStringtoEnglish = sAns
End Function

In a event the following -

Dim xTimeOut, xTimeIn

xTimeOut = rsValuation!TimeCreated
        xTimeIn = Format(time, "hh:mm:ss")
        
        'xTimeOut = Format(time, "hh:mm:ss")
        'xTimeIn = rsValuation!TimeCreated
        
        GetTimeDiff xTimeOut, xTimeIn, txtTimeTaken

'Swop above commented depending on what time came first...

This what you were looking for?

no i'm loooking something like this

if user stored the time value in access liks 10.30 ....
i want to show the table value 10.30 and below that wanna show the time 10.15 in form
...........

Try the following -

'Once you get the value from the database into Text1, do the following

Dim x As Integer

x = DatePart("n", Text1.Text)

Text1.Text = x - 15

All you need to do now is to create some code if the -15 is deducted from say 14:01 as a time format, and you will be on your way to the solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.