Frage

I want display month in a given date by using sqlite date Functions.

For Example 30-March-2012.

I want display only March from that Date.

War es hilfreich?

Lösung

In sqlite u can not get name of the month but you will get number of the month like 01-Jan ,02-Feb etc. You need to convert that number into month by code.

strftime('%m', dateField)

You will get number of month. And using case or nested if condition you can print month name.

Andere Tipps

dateField is the date:

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 

Try this

SELECT left(datename(month, DATEADD(MM,-1,getdate())), 3)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top