Solved

Time Conversion

Posted on 2011-02-12
9
325 Views
Last Modified: 2012-05-11
I need to convert a time that is a string value to a time value only - i want to subtract 2 times to get the difference- it will not allow it because of it being a string?

Trying to accomplish this:

Currently the 15:10:00 and other time is a string.

15:10:00  -  15:01:00  =  9:00
0
Comment
Question by:srodgers45
  • 5
  • 4
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 34880489
Try this formula

mlmcc
Local StringVar strStart := {YourStartTimeSring};
Local StringVar strEnd := "{YourEndTimeSring};
local Timevar tmStart;
local Timevar tmEnd;
local NumberVar nbrSeconds;
local NumberVar nbrMinutes;
local NumberVar nbrHours;

tmStart := TimeValue(strStart);
tmEnd := TimeValue(strEnd);
nbrSeconds := DateDiff('s',DateTime(CUrrentDate,tmStart), DateTime(CurrentDate,tmEnd));
nbrHours := nbrSeconds\3600;
nbrSeconds := nbrSeconds mod 3600;
nbrMinutes := nbrSeconds\60;
nbrSeconds := nbrSeconds mod 60;

TimeValue(nbrHours,nbrMinutes,nbrSeconds);

Open in new window

0
 

Author Comment

by:srodgers45
ID: 34881014
Sorry i should have added that I have a date field that goes with the time - just separate
When I tried the formula above it comes up with all the times starting at 12:00. Do I need to add the date to the time?  When it tried before to do this formula it did not show properly

DTSToDateTime({FDC_Trips.atpsdate}+{FDC_Trips.atpstime})

The time shown on the left in the screen shot is the proper time. The time on the right side is when I use the formula above to convert to datetime value. No sure why it would be different?
error
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34881108
I should have said to display the answer in 24hour format so that 0 hours shows as 0 hours rather than 12

What does the date field have?

mlmcc
0
 

Author Comment

by:srodgers45
ID: 34881125
The format for the date is 01-01-2011
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 100

Expert Comment

by:mlmcc
ID: 34881296
Is the date field a date or string?

mlmcc
0
 

Author Comment

by:srodgers45
ID: 34881333
Sorry, a string
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 34881372
Try

DTSToDateTime({FDC_Trips.atpsdate} &  " "  & {FDC_Trips.atpstime})

mlmcc

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34881377
If you need the date the function expects dates as 2011-01-01

mlmcc
0
 

Author Closing Comment

by:srodgers45
ID: 34883329
That worked. Thanks for the expert help.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
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…

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

14 Experts available now in Live!

Get 1:1 Help Now