I want to view all that logged onto my system Today
(*Yes I want to use dyn query for this *)
LastLogin is of type DateTime
SELECT @.myStatement = ' SELECT LastLogin, surname
FROM #TEMP WHERE ((LastLogin ='+CONVERT(datetime, @.LastLogin)+')
exec(@.myStatement)
Thanks in advanceLooks to me like you're trying to add a date type to a string, you can't do that. You need to make it a string.|||
SELECT LastLogin, surname|||Ehorn where did the parameter go ?|||ehorns showing you how to cast the date conversion into a string. You need to apply that to your code, although its back to front for your example. Basically you need...
FROM #TEMP
WHERE LastLogin >= cast(cast(getdate() as char(12)) as datetime)
cast(@.LastLogin as varchar)
No comments:
Post a Comment