Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating number of days between two dates 2

Status
Not open for further replies.

xscape

Programmer
Apr 18, 2001
144
GB
Hi all,

I need a method of calculating the number of days that have elapsed between two dates. It's to work out the amount of fines payable on an overdue book. So for example, if someone takes a book out that is due back on 02-May-02 (the data format using Oracle's sysdate) and brings it back on 04-May-02 there's two days fine payable. I just need the number of days between the due back date and the actual return date so I can caluculate the fine amount.

Cheers for any help!!

 
ok ...

there's a way using PHP.

if you have $duedate='dd-mm-yyyy'

$due=explode("-",$duedate);
$numberofdays=(time()-mktime(0,0,0,$due[1],$due[0],$due[2])) / (24 * 60 * 60);

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Thanks very much for your help! I found that using SQL to subtract one date from the other then cast it to an integer did exactly what I wanted! Simple but effective ;-) Thanks! Both top suggestions so have a star each! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top