Solved

Working with hours

Posted on 2016-10-03
3
31 Views
Last Modified: 2016-10-03
Hello guys

I am having a problem that must be simple, but I am not being able to solve it.

I have a time in hh:mm:ss:

mTime = '09:30:00'
mMinu = '00:01:25'

I want to increase the Mminu in Mtime so that it can be:  '09:31:25'

When I do this, my time is increase and not crease the time :(

var
  H : Ttime;
  mTime, mMinu : String;
  mTime := '09:30:00'
  mMinu := '00:01:25'

  H := StrToTime(mTime);
  H := H + StrToTime(mMinu);

Open in new window


Why it is increase my time? What should I do to solve this?

thanks
Alexandre
0
Comment
Question by:hidrau
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 41826260
This code works fine for me
procedure TForm1.Button1Click(Sender: TObject);
var
  H: Ttime;
  mTime, mMinu: String;
begin
  mTime := '09.30.00';
  mMinu := '00.01.25';
  H := StrToTime(mTime)+ StrToTime(mMinu);
  showmessage(timetostr(h));
end;

Open in new window

What kind of problem are you having?
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 41826267
Anyway you could use inCsecond function from DateUtils

Something like
uses DateUtils;
  mTime := '09.30.00';
  H := StrToTime(mTime);
  Showmessage(Timetostr(IncSecond(h,85)));

Open in new window

0
 
LVL 1

Author Comment

by:hidrau
ID: 41826270
I solved with your example, it was something very simple but I couldn't see it :)

thanks Ferruccio
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now