如何计算预期每月的星期天的每月数据 [英] how to calculate monthly data expecting sundays of the month

查看:75
本文介绍了如何计算预期每月的星期天的每月数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个月的每一天都有一个表包含31列(DataType int)..
我正在尝试计算除星期日数据以外的月份的总详细信息..
如何通过SQL查询获取所需的数据.


请帮助..

There is a table contains 31 column(DataType int) for each day of a month..
I am trying to calculate for total details of the month excluding sundays Data..
How do I get the desired data through SQL Query.


Please help..

推荐答案

您可能必须从现有数据中获取日期字段:

YourDateField =年+月+数据类型Int列转换为varchar
例如:-``2012''+``01''+ RIGHT(``00''+ CAST(MonthDay AS NVARCHAR(2),2)


You may have to derive your date field from existing data:

YourDateField = Year + Month + DataType Int Column converted to varchar
Eg:- ''2012'' + ''01'' + RIGHT(''00'' + CAST(MonthDay AS NVARCHAR(2), 2)


select * from yourTable
Where UPPER(DATENAME(DW,YourDateField)) <>'SUNDAY'






OR

select * from yourTabl
Where DATEPART(DW,YourDateField) <> 1 -- 1 means Sunday, 2 Monday, ... 7 Saturday


这篇关于如何计算预期每月的星期天的每月数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆