all groups > sql server reporting services > may 2007 >
You're in the

sql server reporting services

group:

Get Saturday's date...


Get Saturday's date... CipherTeKST
5/2/2007 11:17:02 AM
sql server reporting services:
I am building a report that has two parameters that will always be Sunday to
Sunday but I want a text box to show the Saturdays date for the first
parameter which would be the first sunday. Example:
Parameter 1 - 4/15/2007
Parameter 2 - 4/22/2007

I need the text box to read 4/21/2007 which is the saturday of the week that
begins on 4/15.

Any help will be greatly appreciated, Thanks.
--
CipherTeKST
Re: Get Saturday's date... CipherTeKST
5/2/2007 12:18:01 PM
Yes, I can do this in SQL with,
SELECT
CONVERT(VARCHAR(10),DATEADD(wk, DATEDIFF(wk, 5, getdate()), 5),101) as
SATURDAY

I was looking for an expression to use in SSRS.

Thanks for your help though!
--
CipherTeKST
MCSE: Security 2003, CCNA, Security+


[quoted text, click to view]
Re: Get Saturday's date... BERKE Janos
5/2/2007 8:29:26 PM
Hi,

You should create a new dataset to retreive your parameter default. Put this
code in a stored procedure and the result should be the last Saturday:

set datefirst 7

declare @date datetime
set @date = getdate()
while datepart(dw,@date) <> 7
begin
set @date= dateadd(day,-1,@date)
end
select @date

If you are using the datefirst with the default settingd, you should not put
it in the code. Also, you should format your date with CONVERT or CAST
function, if required.

Another way is to write a custom code in SSRS, but I was lazy :)

I hope, it helps for you.

Regards,

Janos

[quoted text, click to view]
AddThis Social Bookmark Button