Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 用于在给定日期显示月份的sqlite函数?_Android_Sqlite_Sql Date Functions - Fatal编程技术网

Android 用于在给定日期显示月份的sqlite函数?

Android 用于在给定日期显示月份的sqlite函数?,android,sqlite,sql-date-functions,Android,Sqlite,Sql Date Functions,我希望使用sqlite日期函数显示给定日期中的月份 例如,2012年3月30日 我希望从该日期起仅显示三月。试试这个 选择左侧(datename(month,DATEADD(MM,-1,getdate())),3)日期字段是日期: select case strftime('%m', dateField) when '01' then 'January' when '02' then 'Febuary' when '03' then 'March' when '04' then 'April'

我希望使用sqlite日期函数显示给定日期中的月份

例如,2012年3月30日

我希望从该日期起仅显示三月。

试试这个

选择左侧(datename(month,DATEADD(MM,-1,getdate())),3)

日期字段是日期:

select case strftime('%m', dateField) when '01' then 'January' when '02' then 'Febuary' when '03' then 'March' when '04' then 'April' when '05' then 'May' when '06' then 'June' when '07' then 'July' when '08' then 'August' when '09' then 'September' when '10' then 'October' when '11' then 'November' when '12' then 'December' else '' end
as month 

在sqlite中,您无法获得月份的名称,但您将获得月份的编号,如1月1日、2月2日等。 您需要按代码将该数字转换为月份

strftime('%m', dateField)
你将得到月数。 使用case或嵌套if条件可以打印月份名称