Solved

Increment Current Time with x seconds

Posted on 2002-05-23
3
154 Views
Last Modified: 2010-04-04
How can I increment the current DateTime with a x amount of seconds? So for example I want to have a TDateTime of Now + 30 secs returning a TDateTime. Remember that if the current time is lets say 20 secs away from the hour it should increment the hour as well. The same with the day if it's a couple of seconds away from the end of the day. Thanx in advance.
0
Comment
Question by:skynergy
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 7029186
function addseconds(aDateTime : TDateTime; Seconds : Integer) : TDateTime;
begin
  result := aDateTime + (seconds / 60 / 60 / 24);
end;

not tested

meikl ;-)
0
 

Author Comment

by:skynergy
ID: 7029256
No, sorry that doesn't work. It doesn't increment now with that number of seconds.
0
 

Author Comment

by:skynergy
ID: 7029290
Oops, it does! Sorry I made a mistake in some other part of my code. Thank you for This simple answer ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question