OpenQuery日期选择

时间:2018-02-09 04:38:42

标签: mysql date openquery

我有以下openquery工作正常但现在我想使用<div id="output"> </div>仅选择事务&gt; = '2017-07-01'但无法获得正确的语法。后端数据库是Informix 我通过谷歌尝试了很多建议而没有成功:(

gl_trans.gl_trans_date

3 个答案:

答案 0 :(得分:0)

修改WHERE子句&amp;的查询使用它添加新的列条件,如下所示。试试这个:

SELECT *
FROM OpenQuery(PRONTO_L01, "SELECT 
gl_trans.gl_accountcode,
gl_trans.gl_amount,
gl_trans.gl_trans_date ,
gl_trans.gl_details
FROM gl_trans
WHERE gl_trans.gl_amount <> 0 AND gl_trans.gl_trans_date >= '2017-07-01'")

答案 1 :(得分:0)

问题在于Informix日期格式为MM-DD-2017,使用DATE函数解析如下

gl_trans.gl_trans_date&gt; = DATE(&#39; 07-01-2017)&#39;&#34;

答案 2 :(得分:0)

     I did something like that and it worked.

    Declare @date DATETIME = '2017-07-01';
    SELECT *
    FROM OpenQuery(PRONTO_L01, 'SELECT 
    gl_trans.gl_accountcode, 
    gl_trans.gl_amount,
    gl_trans.gl_trans_date ,
    gl_trans.gl_details
    FROM gl_trans
    WHERE gl_trans.gl_trans_date  >= ''''' + 
    CONVERT(CHAR(19), @date, 120) + N'''''''))