Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 setup filter in view?

Author  Topic 

mapperkids
Yak Posting Veteran

50 Posts

Posted - 2007-05-16 : 16:39:51
Hi,

If I want to setup a filter for a field which is inside the view. How to do that

I try something like FieldA > = (date()-60), it give me error saying the date()is not a valid built-in function?

Thanks!

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-05-16 : 16:44:54
Try getdate() instead.
Go to Top of Page

mapperkids
Yak Posting Veteran

50 Posts

Posted - 2007-05-16 : 17:11:56
Thanks!

But the fieldA that I want to compare is a string like "07/05/16", so how can I convert the GETDATE() statement to compare it?

I want to filter the view only includes records for two months old
like FieldA > = GETDATE() - 60

Thanks !
Go to Top of Page

sshelper
Posting Yak Master

216 Posts

Posted - 2007-05-16 : 17:16:02
Try converting your FieldA into DATETIME so that it will compare as DATETIME and not as string:

CONVERT(DATETIME, FieldA, 11) >= GETDATE() - 60

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page
   

- Advertisement -