A time of query query the recent 30 day

DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(FROM_UNIXTIME(zxgl_yytime))
The zxgl_yytime field is stored timestamp query the recent 30 day why check out data
From the last 16 months start time end is the farthest time instead of the end of the day
But I change the time field of inquiry is correct
Only this way can detect accurately
DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(FROM_UNIXTIME(zxgl_yytime)) AND date(FROM_UNIXTIME(zxgl_yytime))<=DATE_FORMAT(now(),'%Y-%m-%d')

Started by Gerald at November 29, 2016 - 3:12 AM

For a complete SQL

Posted by Lionel at December 03, 2016 - 3:57 AM

select *,(select u_name from tp_user e where e.u_id=b.zxgl_lrname) as u_name,(select zx_name from tp_zxyytype a where a.zx_id=b.zxgl_mj) as zx_name,(select bz_name from tp_bzgl d where d.bz_id=b.zxgl_ksid) as ks_name,(select bz_name from tp_bzgl f where f.bz_id=b.bz_id) as bz_name,(select hp_yyname from tp_hospitalp c where c.hp_id=b.hp_id ) as hp_yyname from tp_zxyygl b where hp_id in (1,2,3,4,6,7,8,9,10,11,12) AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(FROM_UNIXTIME(zxgl_yytime)) AND date(FROM_UNIXTIME(zxgl_yytime))<=DATE_FORMAT(now(),'%Y-%m-%d') Order by b.zxgl_yytime this is a complete
Check the last 30 days

Posted by Gerald at December 14, 2016 - 4:44 AM

Select * from where DateDiff(now(),zxgl_yytime)<=30

Posted by Warner at December 26, 2016 - 4:55 AM