1

这是我的问题:我的 sqlite 数据库中有一些日期。我想要做的是以下内容:

SELECT dates FROM Table1 WHERE dates > date('now','-1 month');

结果是:

2013-02-21 12:04:22
2013-02-28 12:04:22
2013-02-01 12:04:22

如何将这些日期转换为以下内容:

2013-02-21 12:04:22 become 2 (day 2 of the month)
2013-02-28 12:04:22 become 9 (day 9 of the month)
2013-03-01 12:04:22 become 10(day 10 of the month)

先感谢您

4

2 回答 2

3

尝试

select julianday(dates) - julianday(date('now','-1 month')) + 1
from table1
where dates > date('now','-1 month')
于 2013-03-20T13:04:42.653 回答
0
select cast((julianday(dates) - julianday(date('now','-1 month')) + 1)as int)
from table1
where dates > date('now','-1 month')

只保留整数部分:) 非常感谢 AnatolyS

于 2013-03-20T17:08:15.943 回答