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
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 add parameter to dateadd function

Author  Topic 

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2011-02-08 : 04:16:39
Hi I have the following function in my query in a report and im trying to use a parameter but it complains about the arguement being nvarchar.

DATEADD(dd, @days, GETDATE())

is it not possible to use this?

it is currenrly

DATEADD(dd, -7, GETDATE())

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-02-08 : 04:23:59
How is @days variable declare? As SMALLINT, INT or NVARCHAR?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2011-02-08 : 04:51:48
I havent declared, the parameter just added it in.

DECLARE @PreviousDate datetime

SET @PreviousDate = DATEADD(dd, -7, GETDATE())

----


quote:
Originally posted by Peso

How is @days variable declare? As SMALLINT, INT or NVARCHAR?



N 56°04'39.26"
E 12°55'05.63"


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-02-08 : 05:08:58
quote:
Originally posted by cipriani1984

...it complains about the arguement being nvarchar.

DATEADD(dd, @days, GETDATE())



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-03-03 : 01:17:50
use convert()
Go to Top of Page
   

- Advertisement -