Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 creating a looping function within SRS

Author  Topic 

goombah
Starting Member

1 Post

Posted - 2006-01-17 : 07:53:21
I have used Crystal Reports extensively in the past. I use the following function to determine the weekdays within a given date range:

numberVar dcount := 0;
numberVar numberofdays := DateDiff ('d', Minimum({?Date Range}), Maximum({?Date Range}));
numberVar totalhours := 0;
dateVar datecalc := Minimum({?Date Range});

while dcount <> numberofdays do
( if DayOfWeek (datecalc) in [2,3,4,5,6] then totalhours := totalhours + 8;
datecalc := Date(DateAdd ('d', 1, datecalc));
dcount := dcount + 1;
);totalhours

I have not been able to find a way to accomplish this in SQL Reporting Services 2005. Anyone have some direction to give here?

Thanks......

jhermiz

3564 Posts

Posted - 2006-01-27 : 00:16:22
quote:
Originally posted by goombah

I have used Crystal Reports extensively in the past. I use the following function to determine the weekdays within a given date range:

numberVar dcount := 0;
numberVar numberofdays := DateDiff ('d', Minimum({?Date Range}), Maximum({?Date Range}));
numberVar totalhours := 0;
dateVar datecalc := Minimum({?Date Range});

while dcount <> numberofdays do
( if DayOfWeek (datecalc) in [2,3,4,5,6] then totalhours := totalhours + 8;
datecalc := Date(DateAdd ('d', 1, datecalc));
dcount := dcount + 1;
);totalhours

I have not been able to find a way to accomplish this in SQL Reporting Services 2005. Anyone have some direction to give here?

Thanks......



You will either have to do this in a sproc, or you can create a custom function in the custom code section of the report. Look up the DATE functions in reporting services BOOKS ONLINE.

Thanks,
Jon



Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]

RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page
   

- Advertisement -