Reputation: 46
I want to use one parameter for date and another one for time in my reports as shown below.
Start Time [16/01/2012][12.00 am]
Can anyone help me regarding that?
Upvotes: 1
Views: 5393
Reputation: 13170
Sure it is a multiple step process:
Set up a dataset, 'AvailableDateTime' to combine the two into a legitimate datetime field:
SELECT CAST(@Date + ' ' + @Time AS DateTime) AS Datetime
Set up a third variable of DATETIME to be 'DATETIME' as the variable value and prompt.
You now have set up a separate field for data and time.
Further consideration to avoid user input error. You may wish to tie the first variables to be selectable ONLY FROM values you set in available values or from a query. The problem being if a user fat fingers the date or time it will not run as the system is only trying to combine two strings and make a datetime out of it. You may wish to list values directly from a query from the getgo.
EDIT FOR CHANGING FIRST TWO VARIABLES:
You can set a second dataset up to get available times for an end user:
declare @time table ( tm int)
declare @cursor int = 0
while @cursor <= 23
Begin
insert into @time values (@cursor)
set @cursor += 1
End
select cast(CAST(tm as varchar) + ':00' as time) as HourOfTheDay
from @time
Setting your second variable to get values from a query that is made in step 2 directly above.
You should now be able to put the values together as above.
Upvotes: 1
Reputation: 5114
As I said in my comment, SSRS
does not allow you to have separate parameters for Date
and Time
.
It has only one parameter Date/Time
.
As I see you have two options.
Integer
type, for instance and then create a list
of Available Values
. (see images)Upvotes: 1