Results 1 to 5 of 5

Thread: Fine calculation in a library management system project

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009
    Posts
    904

    Fine calculation in a library management system project

    Hi all,

    I am making a library management project and i am facing problems in fine calculation part. I have Date_Of_Issue and Date_Of_Submission fields (both set to Date/Time datatype) in a table named Book_Details(the database i am using is MS-Access 2003).

    All i want to do is a query which will calculate the difference of days between the Date_Of_Submission and Date_Of_Issue.

    If the difference of days is more than 5,then a fine will be charged by the student on a basis of $5 per day i.e; if the difference of days between the Date_Of_Submission and Date_Of_Issue is 7 days,then a fine of $10 will be charged ny the student.

    How to do this?

    Please please help

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Fine calculation in a library management system project

    This is the 'proper' way:
    Code:
    SELECT Date_Of_Submission, Date_Of_Issue, DateDiff('d', Date_Of_Submission, Date_Of_Issue) as NumDays
    FROM
    ..but due to the way dates are stored internally, you should be able to use this version which is likely to be quicker:
    Code:
    SELECT Date_Of_Submission, Date_Of_Issue, Int(Date_Of_Submission - Date_Of_Issue) as NumDays
    FROM

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009
    Posts
    904

    Re: Fine calculation in a library management system project

    Thanks for the quick reply

    but i cant understand what you mean by the term proper way and much quicker way

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Fine calculation in a library management system project

    Qicker.... Faster then the other. Proper the correct way to do this
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Fine calculation in a library management system project

    The proper way is the method shown in the documentation for Access (and Jet/ACE), and should be understandable by most people. It is also easy to change from Days to any other unit of time (such as Year/Month/Hour/miNute).

    The quicker way uses a bit of advanced knowledge about Access/Jet (dates are stored as numbers, just like they are in VB6 [explanation of date storage etc]), which I expect takes less work, and thus runs faster. Unfortunately it is only valid for Days (or multiples of days, such as Weeks).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width