Android 用于在给定日期显示月份的sqlite函数?
我希望使用sqlite日期函数显示给定日期中的月份 例如,2012年3月30日 我希望从该日期起仅显示三月。试试这个 选择左侧(datename(month,DATEADD(MM,-1,getdate())),3)日期字段是日期: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'
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条件可以打印月份名称