Thiyagarajan
Thiyagarajan

Reputation: 1

How to subtract two date and value will be stored as number(int)?

how to subtract two dates and value will be stored as interger,
like

int a=returndate - issuedate;  

here (a) will be number of days.

like

int a=24-12-2010 - 12-12-2010;  

here a is 12;

Upvotes: 0

Views: 413

Answers (3)

jrharshath
jrharshath

Reputation: 26583

Did you take a look at this? Does it suit what you want?

Upvotes: 0

Bhanu Prakash Pandey
Bhanu Prakash Pandey

Reputation: 3785

use timestamp for this

$a=strtotime(24-12-2010) - strtotime(12-12-2010); 
date('m',$a);//gives number of days

for mysql use DATEDIFF

Upvotes: 1

Adriaan Stander
Adriaan Stander

Reputation: 166396

Have a look at DATEDIFF(expr1,expr2)

Upvotes: 3

Related Questions