473,467 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Subtracting seconds from Datetime

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.

Jun 29 '07 #1
2 8754
Try code similar to the following to get a time 12 seconds before right now:

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

-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005
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.

Jun 29 '07 #2
Paulers <pa**********@gmail.comwrote in news:1183146774.619177.314630
@u2g2000hsc.googlegroups.com:
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))
Jun 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eddie | last post by:
When I subtract dates, I can't figure out what I get out. I first I thought it was in seconds, but that's not it. Then I figured maybe HHMMSS, but that does not seem to be it too. How can I...
11
by: Laery | last post by:
Hi, I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date. I know I could use an...
3
by: nriesch | last post by:
In the documentation, the "Second" property of class DateTime is a value between 0 and 59. In UTC time, approximately every year of so, a leap second is added at 00:00:00 UTC, so as to account...
1
by: Ron | last post by:
How can I find the difference in seconds of two DateTime objects. I have looked at the Subtract method but this gives me back another DateTime object. Thanks, Ron
5
by: Nikeman | last post by:
good day, I simply would like to know as to how I can parse seconds to convert them into equivalent DateTime representation. To be more persice, I have a DirectShow app written in VB.NET, with a...
3
by: Amjad | last post by:
I want to subtract two Date variables and show the result in this format: hh:mm:ss I'm thinking that there might be an easy way of doing that. something like: .... Return...
7
by: TheLostLeaf | last post by:
DateTime tTime = DateTime.Now; ------------------------------------------------------------------------------------------- tTime returns "1:59:00 PM" it never returns seconds. Database field...
5
by: =?Utf-8?B?U2hlbGRvbg==?= | last post by:
Hello - I have about ten integer values that each need to be converted to days, hours, minutes and seconds. I can't seem to find a formula for same that works. These integer values come from a...
3
by: =?Utf-8?B?U2hlbGRvbg==?= | last post by:
Hello - I have various times formatted like 00:00:00, so for example, 01:32:05 would be one thirty-two with five milliseconds. I need to convert this into seconds (an integer). First of...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.