How do you test if something is older than 3 months?

后端 未结 4 1010
再見小時候
再見小時候 2021-02-12 21:36

I have been having some trouble to select the rows of my table which has a date of 3 months prior of today. I tried using DATE(NOW() - INTERVAL 3 MONTH) in my where

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-12 21:47

    try out DATEDIFF:

    SELECT 
        case 
            when DATEDIFF(month, '2005-12-31' , '2006-04-01 ') > 3
            then 'yes'
    
            else 'no'
    
        end
    

    Hope that helps,

    John

提交回复
热议问题