June 26, 2008 at 12:28 am
Hi All,
I am trying to make a report with Microsoft Reporting Service.
I have an datetime type parameter.
In the database my field that I want to filter with time format.
But my parameter is only date and I want to filter datas
which field=my parameter.
I did things as below :
(CONVERT(nvarchar, FireBrigade_ShiftFallows.ActualStartDate, 102) = CONVERT(nvarchar, @date,102))
but it doesn't work.What should I do?
June 26, 2008 at 12:46 am
Excuse my english, but i'm from Spain.
Possible options are:
1) If your parameter is a datetime try:
where convert(char(10), FieldDatetime, 102) = convert(char(10), @ParamDatetime, 102)
2) If your parameter is a string try:
where convert(char(10), FieldDatetime, 102) = convert(char(10), convert(datetime, @ParamChar), 102)
June 26, 2008 at 1:04 am
Hi,
I doesn't work.the parameter is datetime.
June 26, 2008 at 1:56 am
Good morning,
Use the following:
where cast(convert(char(10), FieldDatetime, 102) as datetime) = @ParamDatetime
Good luck let me know if you have any more problems
Niels Naglé
June 26, 2008 at 3:42 am
If you have an index over your field datetime, a better solution that uses your index can be:
WHERE
FieldDatetime >= CONVERT(DATETIME, CONVERT(CHAR(10), @ParamDatetime, 102))
AND
FieldDatetime < DATEADD(dd, 1, CONVERT(DATETIME, CONVERT(CHAR(10), @ParamDatetime, 102)))
June 26, 2008 at 3:30 pm
many ways to skin a cat
not that I would want to skin a real cat...
CAST(CAST(mydate AS VARCHAR(12)) AS DATETIME)
removes the time for comparison purposes
June 26, 2008 at 4:02 pm
based on this:
(CONVERT(nvarchar, FireBrigade_ShiftFallows.ActualStartDate, 102) = CONVERT(nvarchar, @date,102))
I'd do this:
FireBrigade_ShiftFallows.ActualStartDate >= dateadd(dd, datediff(dd, 0, @date), 0) and
FireBrigade_ShiftFallows.ActualStartDate < dateadd(dd, datediff(dd, 0, @date) + 1, 0)
😎
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply