SQLite的ORDER BY月份数字在'YYYY-MM-DD'格式 [英] SQLite ORDER BY month number in a 'yyyy-mm-dd' format
本文介绍了SQLite的ORDER BY月份数字在'YYYY-MM-DD'格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为 call_date
列的表中的 DATETIME
格式。
在此专栏中,我有这种格式在以下日期 YYYY-MM-DD
。
我要的是选择在列的值的字符串月份数字排序的行。
有没有办法,这是否??
这样的SQLite功能我已经尝试过的strftime(%M,call_date)
但ditn't的工作。
感谢。
解决方案
SELECT * FROM myTable的ORDER BY CAST(的strftime(%M,call_date)AS INTEGER);
I have a table with a column named call_date
in the DATETIME
format.
In this column I have the following date in this format yyyy-mm-dd
.
What I want is to select the rows ordered by the month number in the column's value String.
Is there such SQLite function that does that??
I already tried strftime('%m', call_date)
but ditn't work.
Thanks.
解决方案
select * from myTable order by CAST(strftime('%m', call_date) AS INTEGER);
这篇关于SQLite的ORDER BY月份数字在'YYYY-MM-DD'格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文