返回date的mysql中的差异 [英] Return difference in date's mysql
问题描述
我希望返回
start_date
和
account_add_date
$ b $之间的差异b
例如:
用户在 2015年12月1日添加了一个帐户并在 2016年3月1日所以差异是3个月。
我的查询什么都没有返回,有什么问题?
我尝试过:
function get_age(){
$ mem_id = $ this-> session-> userdata('id');
$ query = $ this-> db
- > select(12 *(年('account_add_date') - 年('start_date'))+(月('account_add_date') - 月('start_date'))AS differenceInMonth)
- > where(' mem_id',$ mem_id)
- > get('bank');
返回$ query;
}
mem_id =
this-> session-> userdata('id');
query =
I wish to return the difference between
start_dateand
account_add_date
For Example:
The user added an account on 1st December 2015 and started the account on 1st March 2016 so the difference is 3 months.
My query is returning nothing, what is the problem ?
What I have tried:
function get_age() {
$mem_id = $this->session->userdata('id');
$query = $this->db
->select("12*(YEAR('account_add_date') - YEAR('start_date')) + (MONTH('account_add_date') - MONTH('start_date')) AS differenceInMonth")
->where('mem_id', $mem_id)
->get('bank');
return $query;
}解决方案mem_id =
this->session->userdata('id');
query =
这篇关于返回date的mysql中的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!