Solved

Removing saturday and sunday from ssrs 2008 calendar report

Posted on 2013-11-11
3
603 Views
1 Endorsement
Last Modified: 2013-11-21
I used the following tutorial to create a calendar based report in SSRS. It is working but not exactly to what my requirements are,

My DBMS for scheduling ensures no tasks are added to Saturday's and Sunday's but I am not sure how to reflect that via this report the way it is currently built

Because of the way the query is built, right now tasks that aren't actually scheduled on a Saturday or Sunday are displaying as if they are because I haven't found  a way to filter out those days. I am hoping someone can tell me how to accomplish this.

http://rduclos.wordpress.com/2010/02/13/ssrs-2008-generate-calendars-based-on-a-date-range/

Thanks for any help!
1
Comment
Question by:J C
3 Comments
 
LVL 37

Expert Comment

by:ValentinoV
Comment Utility
Ideally you'd have a Date dimension that contains a column to indicate which day of the week the record represents.  In that case you could just use a WHERE clause to filter out the weekend days.

Another option is to use either the DATEPART or DATENAME function.  Note that the result of DATEPART is influenced by the DATEFIRST setting, as following example indicates:

select DATEPART(dw, getdate())
select DATENAME(dw, getdate())

set datefirst 3;

select DATEPART(dw, getdate())
select DATENAME(dw, getdate())

Open in new window

0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
Comment Utility
Include below highlighted where clause to filter saturday and sunday. HTH.


SELECT
 DisplayOnCalendar = DENSE_RANK() OVER (ORDER BY d.Year, d.Month),
 d.Month,
 [Day] = DATEPART(DAY,d.[Date]),
 d.Year,
 [WeekDay] = DATEPART(WEEKDAY, d.[Date]),
 [Order] = DENSE_RANK() OVER (PARTITION BY d.Year, d.Month ORDER BY d.Date),
 d.Date,
 ebd.FullName
FROM
 Dates d
 LEFT JOIN EmployeeBirthDay ebd ON ebd.Month = DATEPART(MONTH,d.[Date]) AND ebd.Day = DATEPART(DAY,d.[Date])
WHERE ((DATEPART(dw, d.[Date]) + @@DATEFIRST) % 7) NOT IN (0, 1)
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 500 total points
Comment Utility
Code below (also) works regardless of any date or language settings:

WHERE
    DATEDIFF(DAY, 0, d.[Date]) % 7 NOT IN (5, 6)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ssms - object execution statistics 12 37
Need Counts 11 39
Backup Job question 4 16
Optimize/Performance Tune Production Databases 11 36
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now