Finding difference between dates [duplicate]
Possible Duplicate:
trying to get the number of months
I have a
memberpayments table
totalamountpaid
exppaymen开发者_C百科ts
expmonthly payments
dueday
memberid
I want to find the datediff like this way here I have found the date diff using c#
but I want to find the date diff using mysql
double equivalentPayments = totalamountpaid /expmonthly payments;
double monthdiff = Math.Ceiling(exppayments - equivalentPayments);
monthdiff -= 1;
int dueDay = 01;
DateTime expDate = DateTime.Today.AddMonths((int)monthdiff).AddDays(DateTime.Today.Day - dueDay);
int diff = DateTime.Today.Subtract(expDate).Days;
I have tried using Date diff but it was giving the difference between two dates and it was not giving datediff like above solution(c#).
can i get these statements all in one query......using mysql....
would any one pls help me out
MySQL have a large set of date time functions. Finding differences between dates are fairly trivial using them :)
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
If i understand correctly, all you are after is the difference in days between two dates. This can be done with DATEDIFF(a,b) :)
精彩评论