[quoted text, click to view] JT wrote:
> Hi,
> I am trying to run a sproc that includes the following in the WHERE
> clause:
>
> AND (ApptTime BETWEEN @StartTime AND @EndTime)
>
> ApptTime is a datetime data type, as are the two variables. When I
> run the sproc by explicitly setting the variables, I get the desired
> results. I explicitly set the variables as follows:
>
> SELECT @StartTime = CAST('07:00' AS DATETIME)
>
> However, when I pass in the value of @StartTime from my app, it sets
> @StartTime to #01/01/2005 07:00:00#. What I need to do is extract
> just the 07:00 from this. Can anyone give me a suggestion.
> Thanks.
>
> JT
What is the date portion you are working with here? A DATETIME has a
date portion stored as well as the time. So it must be something. If you
only care about the time portion and can set the appropriate date
portion within the procedure, mangle the date there, rather than relying
on the application. I'm not sure this is your case. if not, can you
elaborate on what you are using for the date in the datetime column?
For example, if the procedure always works with the current date, then
you could use:
Parameter @StartTime datetime
Set @StartTime = CONVERT(datetime, CONVERT(varchar(8), getdate(), 112) +
SPACE(1) + CONVERT(varchar(5), @StartTime, 108))
--
David Gugick
Imceda Software
www.imceda.com