Estoy tratando de extraer el mes de un campo DATETIME
en SQLite. month(dateField)
no funciona tan bien como strftime('%m', dateStart)
.Obtenga el mes a partir de DATETIME en sqlite
¿Alguna idea?
Estoy tratando de extraer el mes de un campo DATETIME
en SQLite. month(dateField)
no funciona tan bien como strftime('%m', dateStart)
.Obtenga el mes a partir de DATETIME en sqlite
¿Alguna idea?
No entiendo, la respuesta está en la pregunta:
select strftime('%m', dateField) as Month ...
SELECT strftime('%m', datefield) FROM table
Si usted está buscando el nombre del mes, los nombres de texto meses no parece estar apoyada por la distribución del núcleo de SQLite
Supongo que quiere obtener el mes como una cadena. No es el más amigable pero probablemente veas el punto. Simplemente reemplaza la fecha ('ahora') con tu variable.
select case strftime('%m', date('now')) 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
intente utilizar el siguiente:
select strftime('%m', datetime(datefield, 'unixepoch')) as month from table
esto no es correcto si datefield es un tipo de fecha y hora nativa. Necesita utilizar strftime ('% m', datetime (datefield, 'unixepoch')) como se menciona en otra respuesta. –