select CONVERT(varchar(10), getDate(),120) --不要时间2002-1-1
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108) ---06:05:05
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108) ---06:05:05
format_string为什么会提示"非法函数"?谁能帮帮小弟啊???????
declare @ datetime
set @ = getdate() --'2003-7-1 10:00:00'
SELECT @,DATEADD(Hour, DATEDIFF(Hour,0,@), 0)
------------------------------------------------------ ------------------------------------------------------
2004-03-26 12:28:09.510 2004-03-26 12:00:00.000(所影响的行数为 1 行)
declare @ datetime
set @ = getdate() --'2003-7-1 10:00:00'
SELECT @,DATEADD(day, DATEDIFF(day,0,@), 0)
------------------------------------------------------ ------------------------------------------------------
2004-03-26 12:28:23.973 2004-03-26 00:00:00.000(所影响的行数为 1 行)
SQL环境:SQL-SERVER的"企业管理器"1.FORMAT_STRING使用时为什么总提示"非法函数"?
2.有一名为beginDate的DateTime型字段,有记录值如下:1997-12-31 18:33:20
1997-8-23 10:30:4
1997-2-30 8:42:0
1997-5-5 22:48:01
...
要求找出时间在9:00~12:00的记录(忽略时间),如何找啊????
2.select * from table
where datepart(Hour,beginDate)> 9
and datepart(Hour,beginDate)<= 12
where datepart(Hour,beginDate)>= 9
and datepart(Hour,beginDate)<= 12这句SQL文的作用是9:00~12:00之间的数据都会被显示出来不知道你想得到什么
把你具体的需求贴出来另外你可以查一查datepart函数的用途