这个容易,SQL语句为:
SELECT DATE_FORMAT( now( ) , '%Y-%m-%d' ) AS time;
测试过,可以的

解决方案 »

  1.   

    字段为time,DATE_FORMAT( now( ) , '%Y-%m-%d' )这个语句的now()是当前时间,这个还可以是其它的日期DATE_FORMAT是MYSQL的函数,日期格式化,%Y-%m-%d是格式形式
      

  2.   

    能够得到这样格式的时间  2008-12-03      2007-11-13。    
    编写sql语句实现这样几个统计信息: 
    今日统计:slect * from a where  时间是今天(怎么表达) 
    本月统计:slect * from a where  时间是本月(怎么表达) 
    今年统计:slect * from a where  时间是今年(怎么表达) 
      

  3.   

    今日统计:"slect * from a where  tempDate='".date("Y-m-d")."'"
    本月统计:"slect * from a where  MONTH(tempDate)='".date("m")."'"
    今年统计:"slect * from a where  YEAR(tempDate)='".date("Y")."'"
      

  4.   

    楼主的意思也就是要实现按时间查询表中内容:1.在建表的时候要把数据存入数据库的日期记入库中,假如记为year,mon,date;2.存入数据库前计算今天的时间:$year=date('Y');$mon=date('n');$date=date('j');具体时间不用管了3.在统计数据的时候就可以实现楼主想要的效果了:在查询之前,计算现在的 $year,$mon,$date,计算方法同上!今日统计:slect * from a where  date=$date;
    本月统计:slect * from a where  mon=$mon; 
    今年统计:slect * from a where  year=$year;
      

  5.   


    今日统计:"slect count(*) as countnum from a where  tempDate='".date("Y-m-d")."'"
    本月统计:"slect count(*) as countnum from a where  MONTH(tempDate)='".date("m")."'"
    今年统计:"slect count(*) as countnum from a where  YEAR(tempDate)='".date("Y")."'"
    tempDate为你表中的时间字段。
      

  6.   


    不好意思,上面的本月统计漏了个条件:"slect * from a where  MONTH(tempDate)='".date("m")."' and YEAR(tempDate)='".date("Y")."'"
      

  7.   

    select  date_format(now(),get_format(date,'iso')) as date;
      

  8.   

    date("Y-m-d")得到的时间是今天,昨天该如何表达?
      

  9.   

    昨天的:
    $sql = 'slect * from a where  tempDate=DATE_SUB('.date("Y-m-d").',INTERVAL 1 DAY)'
      

  10.   

    先计算出昨天的日期:
    $time=time()-24*60*60; //昨天的时期戵$date=date('Y-m-d',$time); //昨天的格式后日期
    昨日统计:"slect * from a where  tempDate='".$date."'"