• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to calculate fine for library

 
sarathd kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All... i am working on library task i need someone delay to return book i want add fine for how many extra day he will take to return a book

this is i am working so far..

select
( cast(CURDATE() as date) - cast(rdate as date) ) * 3 as fine
from issues
where
rdate > CURDATE()

thanks for advance...
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems you have the "fine" calculated in the sql as (current date - date in DB) * 3. I presume the "3" in whatever currency is the late charge. So the date difference * 3 gives you the fine.
 
Junilu Lacar
Marshal
Posts: 10410
125
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Edit: post has since been moved from JSP forum to JDBC forum] -- Also, how does this relate to JSPs? I hope you're not trying to run a SQL query in your JSP... that would be bad form. The only kind of logic that you should have in JSPs is logic that relates to displaying and formatting information that has already been processed elsewhere in your program.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that rdate is the date the book was due, I'd say your approach is in the right direction. Which difficulties are you encountering?
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!