tags:

views:

30

answers:

1

how can we extract system time in vb and do calculation ie. adding or subtracing time then store change time in oracle database table in earlier format .

+4  A: 

To get the system time

Dim timestamp As Date: timestamp = Now
timestamp = timestamp - Int(timestamp)

To add or subtract a time interval (e.g. add one hour)

timestamp = DateAdd("h", 1, timestamp)

To store it in a database, something like

Dim cnn As New Connection
cnn.ConnectionString = "YourConnectionString"

Dim cmd As New Command
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "YourStoredProcName"
cmd.ActiveConnection = cnn

Dim prm As Parameter: Set prm = cmd.CreateParameter("YourParameterName", adDBTime, adParamInput)
prm.Value = timestamp

Call cmd.Parameters.Append(prm)
Call cnn.Open
Call cmd.Execute
Call cnn.Close
AdamRalph
@AdamRalph: how about decrementing time ? DateSub() not working ...
banita
fine by taking negative value its working thanks .
banita
you're welcome. if you feel I've answered your question, don't forget to accept my answer by clicking the large tick mark
AdamRalph