select c.id
,c.title
,ct.title as sub_title
,case when c.start_date is NULL or c.start_date="0000-00-00 00:00:00" then now() else c.start_date end as start_date
,case when c.end_date is NULL or c.end_date="0000-00-00 00:00:00" then now() else c.end_date end as end_date
,case when c.start_date is NULL or c.start_date="0000-00-00 00:00:00" then 1 else 0 end as start_is_null
,case when c.end_date is NULL or c.end_date="0000-00-00 00:00:00" then 1 else 0 end as end_is_null
,DATE_FORMAT(now(),"%Y%m%d") = DATE_FORMAT(c.start_date,"%Y%m%d") as is_show_now
,published
,c.full_content
from systems_contents sc
left join contents c
on c.id = sc.contents_id
left join contents_type ct
on ct.type_id="0"
where sc.systems_id="13"
and c.calendar_show="1"
-- and (c.end_date >= now() or c.end_date is NULL or c.end_date="0000-00-00 00:00:00")
and (c.end_date >= now())
and c.end_date <= CURDATE() + INTERVAL 1 YEAR
and c.published = 1
order by start_date
limit 10
rec is 0