2

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.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Venkat
  • 343
  • 1
  • 7
  • 17

3 Answers3

2

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 
Vikram
  • 8,235
  • 33
  • 47
1

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.

Dhruvisha
  • 2,538
  • 1
  • 21
  • 31
0

Try this

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

Sunil Chavan
  • 524
  • 5
  • 15