select need from t_test where
(cast(convert(varchar(8),getdate(),114) as datetime) between cast(startdate as datetime) and cast(enddate as datetime)) and mainid = ...
(cast(convert(varchar(8),getdate(),114) as datetime) between cast(startdate as datetime) and cast(enddate as datetime)) and mainid = ...
getdate()>startdate and getdate()<enddate这里Startdate和enddate为时间,把它们转为日期加时间既可。