MySQL Forums
Forum List  »  Triggers

Re: Calculation from time stamps through to amount due
Posted by: Brahmanatha Swami
Date: September 03, 2016 06:51PM

Sorry I was not explicit enough

Developer start_time end_time elapsed rate amount_due

Peter 2016-04-10 21:00:00 2016-04-11 02:00:00 5 $40.00 $200.00

where
start_time
end_time
rate

are static data entries being posted to the webserver from a desktop client via CGI/POST

and

elapsed and amount_due are generated by the trigger

This is working:

set new.elapsed=(TIMESTAMPDIFF(MINUTE , new.start_time , new.end_time ) / 60.00)

to generate the "5" (hours) so I get the elapsed time; now we to take the next step and times that by the rate to get amount_due

set new.elapsed=(TIMESTAMPDIFF(MINUTE , new.start_time , new.end_time ) / 60.00);
set new amount_due = (elapsed * rate)'
throws an error.

I'm looking around to do my homework but not seeing examples of this kind of sequential calculation where new values obviously have to be "rendered" first and then operated on, second.

yes, you are proably right, but how to "check for elapsed" before doing the next calculation?

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Calculation from time stamps through to amount due
861
September 03, 2016 06:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.