如何在sqlite中获得前一年

时间:2016-11-27 00:30:29

标签: sqlite

我试图在SQLite where子句中使用sql子句获得前几年。那没起效。有人能帮助我吗?

以下是我想要的内容:

     select * from Spending where strftime('%Y',Spending_DT )<= strftime('%Y', date('now'))-3; 

是导致问题的数字。在我看来,substract 3在select子句中起作用,例如:

    select  strftime('%Y', date('now'))-3;
    output=2013

但是当在where子句

中使用相同的短语时它不起作用

非常感谢

Jing

1 个答案:

答案 0 :(得分:0)

尝试按比例投射比较器的两侧:

示例

quat.w = cos(angle);
quat.x = axis.x* sin(angle / 2.0);
quat.y = axis.y* sin(angle / 2.0);
quat.z = axis.z* sin(angle / 2.0);

<强>查询

void Quaternion::QuatToMatrix(Quaternion& a, GLfloat* matrix)

// First row
matrix[0] = 1.0f - 2.0f * (a.y * a.y + a.z * a.z);
matrix[1] = 2.0f * (a.x * a.y - a.w * a.z);
matrix[2] = 2.0f * (a.x * a.z + a.w * a.y);
matrix[3] = 0.0f;
// Second row
matrix[4] = 2.0f * (a.x * a.y + a.w * a.z);
matrix[5] = 1.0f - 2.0f * (a.x * a.x + a.z * a.z);
matrix[6] = 2.0f * (a.y * a.z - a.w * a.x);
matrix[7] = 0.0f;

// Third row
matrix[8] = 2.0f * (a.x * a.z - a.w * a.y);
matrix[9] = 2.0f * (a.y * a.z + a.w * a.x);
matrix[10] = 1.0f - 2.0f * (a.x * a.x + a.y * a.y);
matrix[11] = 0.0f;

// Fourth row
matrix[12] = 0;
matrix[13] = 0;
matrix[14] = 0;
matrix[15] = 1.0f;

<强>结果

select * from test;
spending_Dt
-----------
2012-03-03
2013-03-03
2014-03-03
2015-03-03
2016-03-03