日期:2014-05-16  浏览次数:20914 次

SQL函数在MS SQL SERVER中可以mysql不行!
时间是2012-12-12 12:12:12
现在我要把后面的时、分、秒 去掉 
select data_Start = convert(varchar(10),data_Start ,120) from Statistical
显示的没有时、分、秒 只有2012-12-12
放到mysql中报错
mysql 语句如下:

select date=convert(varchar(10),date ,120) from owa_isa
错误提示:
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARCHAR(10) date 120) from owa_isa' at line 1

------解决方案--------------------
探讨

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

------解决方案--------------------
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)