SET data_Start= DATE_FORMAT(data_Start,'%Y-%m-%d') OR SET data_Start= date(data_Start)
原来如此!那大哥如果我要在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,时间字段)
select sum(使用流量的和),datepart(week,时间字段)as t from Statistical where 1=1 group by datepart(week,时间字段) 上面的是sql得到每周的记录 mysql 中怎么写呢!我是想把每周的使用流量的sum求出来!
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)
+-------------+
| date(now()) |
+-------------+
| 2012-09-18 |
+-------------+
1 row in set (0.00 sec)
select DATE_FORMAT('2012-12-12 12:12:12','%Y-%m-%d')
select 时间字段=convert(varchar(10),时间字段,120) from owa_isa
我现在读取不要显示时 分 秒 上面的在sql中可以,到mysql中不行!why!
SET data_Start= DATE_FORMAT(data_Start,'%Y-%m-%d')
OR
SET data_Start= date(data_Start)
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,时间字段)
from Statistical where 1=1 group by datepart(week,时间字段)
上面的是sql得到每周的记录
mysql 中怎么写呢!我是想把每周的使用流量的sum求出来!
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)
下表介绍如何模式的论点的作品第一天
模式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
给力!