October 12, 2011 at 2:19 am
Hi All
I have created a report, and I am trying to get it so users can enter X amount in a parameter and this will substract the number or hours from the current date and time.
Example if a user puts in 5 in the parameter this is minus 5 hours from the current time.
I have used the dateadd function and it works if I physcially put in the number in the query but it does not like it when I put in the parameter. The error is "Operand date type datetime is invalid for minus operator"
If I take the Minus out I get the following error "Argument data type datetime is invalid for argument 2 of dateadd function"
I have tried to use convert to change the parameter to an integar but SSRS says it does not recognise INT as a function. Also tried to use convert varchar to no avail. Ive tried with brackets with out, But I may be getting the coding wrong...Can some advise please?
dateadd(HH, -(@hours), getdate()))
Thanks
R
October 12, 2011 at 6:45 am
I found the resolution you have to add CAST(@HOURS as INT)
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply