mysql get month from timestamp not working -


i have query pulls correct data form db, not return me month timestamp. in timestamp column null value, though timestamp exsists. stores in db bigint (this wasnt idea).

what need date returned this:

course |  fcpd   |   month 216    0.5         04 

but get:

course |  fcpd   |   month 216    0.5        null  select mdl_quiz.course, mdl_quiz.fcpd, month(mdl_quiz_grades.timemodified) month mdl_quiz inner join mdl_quiz_grades on mdl_quiz.course = mdl_quiz_grades.quiz mdl_quiz_grades.userid = 9428 , mdl_quiz.course = 215 

could point out going wrong?

you need convert timestamp date first, before can apply month() function.

month(mdl_quiz_grades.timemodified) 

becomes

month(from_unixtime(mdl_quiz_grades.timemodified)) 

read more here.

and sidenote, int enough timestamp, bigint not necessary. timestamp 32bit number, that's why can hold maximum date of january 19, 2038.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -