sqlite选择日期条件
发布时间:2020-12-12 19:16:31 所属栏目:百科 来源:网络整理
导读:我有一个带有出生日期的sqlite表。我想执行一个查询来选择那些年龄超过30的记录。 我尝试了以下操作,但它不起作用: select * from mytable where dob '1/Jan/1980'select * from mytable where dob '1980-01-01' 可以使用这样的一些东西: select dateofbi
我有一个带有出生日期的sqlite表。我想执行一个查询来选择那些年龄超过30的记录。
我尝试了以下操作,但它不起作用: select * from mytable where dob > '1/Jan/1980' select * from mytable where dob > '1980-01-01'可以使用这样的一些东西: select dateofbirth from customer Where DateofBirth BETWEEN date('1004-01-01') AND date('1980-12-31'); select dateofbirth from customer where date(dateofbirth)>date('1980-12-01'); select * from customer where date(dateofbirth) < date('now','-30 years'); 如果您使用的是Sqlite V3.7.12或更高版本 不要使用date(生日)只是使用dateofbirth。所以你的查询如下所示: select * from customer where dateofbirth < date('now','-30 years'); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |