Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to calculate fine for library  RSS feed

 
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: 3648
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
Sheriff
Posts: 11428
173
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!