本帖最后由 ACMAIN_CHM 于 2012-09-18 22:29:30 编辑

解决方案 »

  1.   

    mysql> select date(now());
    +-------------+
    | date(now()) |
    +-------------+
    | 2012-09-18  |
    +-------------+
    1 row in set (0.00 sec)
      

  2.   

    select date('2012-12-12 12:12:12')
      

  3.   

    or
    select DATE_FORMAT('2012-12-12 12:12:12','%Y-%m-%d')
      

  4.   

    看来我要写的具体点!
    select 时间字段=convert(varchar(10),时间字段,120) from owa_isa
    我现在读取不要显示时 分 秒 上面的在sql中可以,到mysql中不行!why!
      

  5.   

    楼上几层已经给了你很多种方法了。至于你的 convert(varchar(10),时间字段,120) 这是SQL SERVER自己定义的格式,并不是SQL标准格式要求,不光MYSQL不行,其它厂商的数据库产品比如DB2,ORACLE, 也不支持。 如果为什么WINDOWS中的命令在LINUX下不能使用相同的道理。
      

  6.   

    MYSQL没有这个函数
     
    SET data_Start= DATE_FORMAT(data_Start,'%Y-%m-%d')
    OR
    SET data_Start= date(data_Start)
      

  7.   

    原来如此!那大哥如果我要在mysql中实现这个问题,该怎么实现呢!
    select DATE_FORMAT('2012-12-12 12:12:12','%Y-%m-%d') select DATE_FORMAT(date,'%Y-%m-%d') from owa_isa大哥下子把 '2012-12-12 12:12:12' 换成字段好吗?谢谢了各位了!
    还有最后一个问题,谁让你们那么强呢!百度有的人都乱写的!
    就是得到当年的每周怎么写!sql中可以得到 mysql中怎么写的呢各位前辈!
    sql中可以,是这样写的!select sum(使用流量的和),datepart(week,时间字段)as t
    from Statistical where 1=1 group by datepart(week,时间字段)
      

  8.   

    select sum(使用流量的和),datepart(week,时间字段)as t
    from Statistical where 1=1 group by datepart(week,时间字段)
    上面的是sql得到每周的记录
    mysql 中怎么写呢!我是想把每周的使用流量的sum求出来!
      

  9.   

    WEEK(date[,mode]) This function returns the week number for date. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used. See Section 5.2.3, “System Variables”. The following table describes how the mode argument works.   First day     
    Mode of week Range Week 1 is the first week … 
    0 Sunday 0-53 with a Sunday in this year 
    1 Monday 0-53 with more than 3 days this year 
    2 Sunday 1-53 with a Sunday in this year 
    3 Monday 1-53 with more than 3 days this year 
    4 Sunday 0-53 with more than 3 days this year 
    5 Monday 0-53 with a Monday in this year 
    6 Sunday 1-53 with more than 3 days this year 
    7 Monday 1-53 with a Monday in this year select sum(使用流量的和),week(时间字段,1)as t
    from Statistical where 1=1 group by week(时间字段,1)
      

  10.   

    这个函数返回的周数日期。非形式的week()允许您指定是否在星期日或星期一开始的一周,返回值应该在范围从0到53或1 - 53。如果模式参数被省略,价值的default_week_format系统变量的使用。见第5.2.3,“系统变量”。
    下表介绍如何模式的论点的作品第一天
    模式1周每周范围是第一周…0个星期日与星期日在这一年0 - 53
    1个星期一0 - 53与超过3天的这一年
    2个星期日与星期日在今年1
    3个星期一1与超过3天的这一年
    4个星期日0 - 53与超过3天的这一年
    5个星期一与星期一在这一年0 - 53
    6个星期日1与超过3天的这一年
    7个星期一与星期一在今年1
    给力!