返回date的mysql中的差异 [英] Return difference in date's mysql

查看:67
本文介绍了返回date的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_date

and

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆