Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Time

Status
Not open for further replies.

heydyrtt

Programmer
Dec 12, 2001
63
US
Hello;

Trying to calculate the time from two time fields, both fields are time fields in the table (mysql database). This works when I just query the table from mysql, but can't get it to work in cpp. The Time column is for the total time spent which will be like 2:00 for two hours.

SELECT starttime, endtime,sec_to_time(time_to_sec(end_time) - time_to_sec(start_time))AS Time ");
FROM ots_report

When I run the query in cpp, I get this message
Type Mismatch for field 'Time' expecting: String actual: Time

Any help

Thanks


Heydyrtt
 
I THINK that querys in BCB can only return strings and you are returning a time. Since you are grabbing the endtime and starttime, why not calc the difference in the program instead of the query?


James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
Yeah, that's what I was doing at first, which I guess I'll go back too. The problem I'm having is after I subtract the two times my result is 02:00AM, I just want a 2 or 02:00 will be fine, is there a way I could trim the AM or PM off.


Thanks


Heydyrtt
 
i suggest u look at something like
HourSpan or HoursBetween in your borland help. will save u some time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top