sqlite3日期和间隔函数 [英] sqlite3 date and interval functions

查看:219
本文介绍了sqlite3日期和间隔函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道sqlite3是否支持间隔功能。 PostgreSQL接受以下语句,但是sqlite3无法解析它;

I wonder whether sqlite3 supports interval function. The following statement is accepted by PostgreSQL, however sqlite3 failed to parse it;

select
 ...
from 
 orders
where
 ...
 and o_orderdate < date '1995-03-01' + interval '3' month 

错误:靠近第4行:靠近'1995-03-01':语法错误

Error: near line 4: near "'1995-03-01'": syntax error

然后,我对语句进行了一些修改,例如;

Then, I modified the statement a little bit such as;

and o_orderdate < date('1995-03-01') + interval '3' month

这次错误是;
错误:在第4行附近:在'3'附近:语法错误

This time the error was; Error: near line 4: near "'3'": syntax error

不幸的是,相同的技巧对间隔函数无效,即

Unfortunately, same trick did not work for the interval function i.e.

and o_orderdate < date('1995-03-01') + interval('3' month)

and o_orderdate < date('1995-03-01') + interval('3') month

甚至

and o_orderdate < date('1995-03-01') + interval(3 month)

仍然给了我语法错误。

也许sqlite3不支持间隔函数,或者我在使用它时缺少某些东西吗?

Maybe sqlite3 does not support interval function or am I missing something in its usage?

谢谢lot

推荐答案

and o_orderdate < date('1995-03-01', '+3 month')

SQLite中日期和时间函数的引用

这篇关于sqlite3日期和间隔函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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