-
Dateadd in RS
Hi
Hope someone can help.
I've got to produce a report that filters information dependent on the purchase date based on various parameters.
The parameters are:
@yearend (Datetime)
@months(int)
the script that I wrote in SQL is
select assetno from assets where purch_date < = dateadd(mm,-@months, @yearend)
but when I try to use this in the dataset it comes up with the following error:
"Application usess a value of the wrong type for the current operation"
Any help would be very much appreciated.
-
What's data tpye of purch_date? How does the value in it look like? How does @yearend look like?
-
Hi
Purch_date is a datetime format, example = 2005-02-07 00:00:00.000
@yearend is a parameter set to datetime format and looks the same as above.
-
USE the following to determine if there are records in assets
table having purch_date in wrong format (that would be very very strange)
SELECT * FROM assets WHERE ISDATE(purch_date) <> 1
if the above statement returns rows, then there is a problem with data of table.
you could use the following query to retrieve the records,
you are looking for:
select assetno from assets where DATEDIFF(dd, purch_date, dateadd(mm,-@months, @yearend) ) > = 0
HTH
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|