A common problem in T-SQL is matching date to a datetime column.
Below is one method to get the records requested, by stripping out
the time portion of the field.
select stock_price
from wall_street_data
where convert(varchar(10),price_dt,101) = '03/08/2007'
and ticker = 'WAG'
go
-- summary
datepart* get part of a date datepart(MM,'10/21/98')=10
dateadd* manipulate a date dateadd(DD,10,'10/21/98')= 10/31/98
getdate todays date and time getdate()=Nov 16 1998-2000 7:27PM
* date parts are MM,DD,YY,HH,MI,SS,MS
|
|