mysql get month from timestamp not working

前端 未结 2 1443
谎友^
谎友^ 2021-01-13 09:05

I have a query that pulls the correct data form a db, but it does not return me the month from the timestamp. In the timestamp column I get a null value, even though the tim

相关标签:
2条回答
  • 2021-01-13 09:31

    You need to convert the timestamp back to a date first, before you can apply the MONTH() function.

    MONTH(mdl_quiz_grades.timemodified)
    

    becomes

    MONTH(FROM_UNIXTIME(mdl_quiz_grades.timemodified))
    

    Read more about it here.

    And as a sidenote, int is enough for a timestamp, bigint is not necessary. A timestamp is a 32bit number, that's why it can hold the maximum date of January 19, 2038.

    0 讨论(0)
  • 2021-01-13 09:41
    "SELECT count(*) as records FROM sms WHERE MONTH(tarih)=MONTH(NOW()) and ceptel='"&ceptel&"'"
    
    0 讨论(0)
提交回复
热议问题