MySQL Forums
Forum List  »  Triggers

Re: Calculation from time stamps through to amount due
Posted by: Kailas Natha
Date: September 05, 2016 02:46PM

Odd... I thought for sure I had posted a "success" reply yesterday...

Your method of running the SQL helps (of course) and I intuited that "new.rate" was required... also "BEFORE" insert works but AFTER does not..

this is working now:

delimiter go

CREATE trigger calculate_time_rate
BEFORE insert
ON admin_time_tracker
FOR each row


BEGIN
set new.elapsed=(TIMESTAMPDIFF(MINUTE , new.start_time , new.end_time ) / 60.00),
new.amount_due=(new.elapsed * new.rate)

END;
go
delimiter ;

Case closed.

Peter, thank you for your patient hand-holding. I'm sure dealing with untrained, inexperienced newbie MySQL hackers can be exasperating at times. We all appreciate your generous work in responding to us! Cheers from Hawaii. (I live on Kauai)

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Calculation from time stamps through to amount due
1083
September 05, 2016 02:46PM


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.