Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
Posted

1 solution

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)


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


OR
SQL
select * from yourTabl
Where DATEPART(DW,YourDateField) <> 1 -- 1 means Sunday, 2 Monday, ... 7 Saturday
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900