sqlserver当前属于哪个季度_sqlserver按年季度月周查询语句(SQL server queries the statement in the annual quarter month)....

sqlserver按年季度月周查询语句(SQL server queries the statement in the annual quarter month)

sqlserver按年季度月周查询语句(SQL server queries the statement in the annual quarter month)

Select month (cast (I _ of the datetime)) from str001 _ LDA where cast (I _ of the datetime) between cast (2010 - 10 - 10 'the datetime) and cast (2010 - 11 - 11' the datetime) group by month (cast (I _ of the datetime))

- 按日

Select convert (varchar (10), I _, 120) from str001 _ LDA where I _ of between '2010 - 10 - 10' and '2010 - 11 - 11' group by convert (varchar (10), I _, 120)

- 按周

Select datename (week, I _ of) the weeks, count (I _ in the usercount)

From str001 _ LDA

Where I _ of between '2010 - 10 - 10' and '2010 - 11 - 11'

Group by datename (week, I _)

- 按月

Select datename (month, I _ of) the month, count (I _ in the usercount)

From str001 _ LDA

Where I _ of between '2010 - 10 - 10' and '2010 - 11 - 11'

Group by datename (month, I _)

----------------------------------------------------------

Datename

SQL datename是返回代表指定日期的指定日期部分的字符串.

语法

Datename (datepart, date)

参数

Datepart

是指定应返回的日期部分的参数.下表列出了 Microsoft? SQL Server? 识别的日期部分和缩写.

Year YY, yyyy quarter QQ, Q month mm, m dayofyear Dy, y day DD, D week wk, WW weekday DW hour HH minute MI, N second SS, s millisecond MS

日期部分 缩写

Weekday (DW) 日期部分返回星期几 (星期天、星期一等).

是返回 datetime 或 smalldatetime 值或日期格式字符串的表达式.对 1753 年 1 月 1 日之后的日期用datetime 数据类型.更早的日期存储为字符数据.当输入 datetime 值时, 始终将其放入引号中.因为 smalldatetime 只精确到分钟, 所以当用 smalldatetime 值时, 秒和毫秒总是 0.有关指定日期的更多信息, 请参见 datetime 和 smalldatetime.有关时间值指定的更多信息, 请参见时间格式.

如果只指定年份的最后两位数字, 则小于或等于 two digit year cutoff 配置选项的值的最后两位数字的值所在世纪与截止年所在世纪相同.大于该选项的值的最后两位数字的数字所在世纪为截止年所在世纪的前一个世纪.例如, 如果 two digit year cutoff 为 2050 (默认), 则 49 被解释为 2049,50 被解释为 1950.为避免模糊, 请使用四位数字的年份.

返回类型

Nvarchar

注释

SQL Server 自动在字符和 datetime 值间按需要进行转换, 例如, 当将字符值与 datetime 值进行比较时.

示例

此示例从 getdate 返回的日期中提取月份名.

Select datename (month, getdate ()) the month name '

下面是结果集:

Month name

------------------------------ February

-----------------------------------------------------------------------------

一、年度查询

查询 本年度的数据

Select *

From the blog _

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值