MySQL查询中时间转换--UNIX_TIMESTAMP()和from_unixtime()的使用

--财年精华主题帖查询(根据时间段查询)
--将时间戳转换为当前时间格式
--将时间格式转换为时间戳
SELECT
z.tid as 主题ID,
z.author as 会员名,
z.authorid as 会员id,
z.subject as 标题,
from_unixtime(z.dateline) as 发表时间, 
CASE z.digest
   WHEN 1 THEN '是'
   WHEN 0 THEN '否'
END AS 是否精华,
z.views as 浏览次数,
z.replies as 回复次数,
CASE z.highlight
   WHEN 1 THEN '是'
   WHEN 0 THEN '否'
END AS 是否高亮,
CASE z.moderated
   WHEN 1 THEN '是'
   WHEN 0 THEN '否'
END AS 是否被管理员改动,
CASE z.stickreply
   WHEN 1 THEN '是'
   WHEN 0 THEN '否'
END AS 是否有回帖置顶,
z.recommends as 推荐次数,
z.heats as 主题热度值,
CASE z.isgroup
   WHEN 1 THEN '是'
   WHEN 0 THEN '否'
END AS 是否为群组帖子,
z.favtimes as 主题收藏次数,
z.sharetimes as 主题分享次数,
z.comments as 点评数
FROM zl_forum_thread z
WHERE
z.digest = 1
AND(z.dateline >UNIX_TIMESTAMP('2016-04-01 00:00:00') AND z.dateline ORDER BY z.dateline DESC

你可能感兴趣的:(MySQL查询中时间转换--UNIX_TIMESTAMP()和from_unixtime()的使用)