Subtracting seconds from Datetime

P

Paulers

hello all,

how does one go about subtracting seconds from a DateTime object?

for example I have a date time of "06/04/2007 10:31" and I need to
subtract 12 seconds from that.

all help is greatly appreciated.
 
T

Tim Patrick

Try code similar to the following to get a time 12 seconds before right now:

Dim newDate As DateTime = Now.AddSeconds(-12)
 
G

Guest

hello all,

how does one go about subtracting seconds from a DateTime object?

for example I have a date time of "06/04/2007 10:31" and I need to
subtract 12 seconds from that.

all help is greatly appreciated.

You can use .Subtract (and pass in a Timespan object) or .Add with a
negative value.

i.e. SomeDateHere.Add(-12) OR SomeDateHere.Subtract(New Timespan(0,0,12))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top