宏鹏教育光谷校区

宏鹏教育光谷校区

  • 宏鹏教育鲁广校区
  • 宏鹏教育光谷校区
  • 宏鹏教育宏鹏IT校区
  • 荆州青鸟之家
  • 襄阳青鸟之家

17740513250

百日千才

一些常用的mysql日期函数

2011-07-27 15:10:25来源:武汉宏鹏教育光谷校区作者:宏鹏教育宏鹏光谷校区

  记录一些常用的mysql日期函数

  1、查询当天数据

  sql = 'select * from article where add_time = CURDATE()'

  2、查询昨天数据

  sql = 'select * from article where to_days(now()) - to_days(add_time) = 1'

  3、查询指定周的数据

  $week_index = date("W")

  sql = "select * from article where WEEKOFYEAR(add_time) = $week_index"

  4、查询指定月的数据

  $month_index = date('m')

  sql = "select * from article where MONTH(add_time) = $month_index"

关闭

只为了方便您就学 宏鹏教育光谷校区 宏鹏教育光谷校区

武汉市江夏区庙山街道华泰街16号(宏鹏教育综合大楼)

Copyright (c) 2006-2024 武汉宏鹏教育咨询有限公司 版权所有 All Rights Reserved.